추가를 위해 간단한 계산기를 만들려고하고 있는데 문제가 있습니다.오류 : 함수 호출에 할당 할 수 없습니다.
print('welcome to calculator') # Print opening message
print(' ') #Spacer
int(sum1) = input('number') # Get input for first number, this variable later becomes the sum : ERROR: Can't assign to function call
int(add1) = input('number') # Get input for second number : Assumed error for this line as well
sum1 = sum1 + add1 # Add the variables together to get the sum
print(str(sum1)) # Change the sum to a string and print it
loop = 1 # Set loop to True
while loop == 1: # Continue the program until user inputs add1 as '0'
int(add1) = input('number') # Get value for add1
if add1 == 0: # Stop the program when add1 is equal to 0
loop = 0 # Set loop to false
break
sum1 = sum1 + add1 # Add the variables together to get the new sum
print(str(sum1)) # Change the sum to a string and print it
print('done!') # Print ending message
여기 오류는 세 번째 줄에 있습니다 (그리고 네 번째 오류도 있다고 가정합니다). 원래는 단지
sum1 = input('number')
을 가지고 있지만, SUM1 변수와 ADD1를 추가 할 수있을 때 변수 SUM1은 서로의 끝 부분에 문자열을 추가, 5 행에, 그래서 문자열로 취급되고 있었다. (예 : 15 + 10 = 1510)
변수를 정수로 변환 할 때 내가 잘못된 일을하고 있습니까? 아니면이 문제를 해결하기 위해 잘못된 방법입니까?
이 Python 2 또는 Python 3입니까? 파이썬 2 인 경우'input()'대신'raw_input()'을 사용해야합니다. –