Skip to content
Advertisement

Variable name gives Syntax error (Python)

I am having a problem with a simple program I made.

num2 = 0
num1 = 1
print ("Enter a number one after another to sum them up, and when you're done type 0")
while num1 != 0:
    num1 = float(raw_input ("Please enter a number:")
    num2 += num1
if num1 == 0:
    print ("The sum of the numbers is:" + str(num2))

For some reason the line num2 += num1 gives me a syntax error on num2.

Advertisement

Answer

You missed one ), closing parenthesis, here:

    num1 = float(raw_input ("Please enter a number:")

should be

    num1 = float(raw_input ("Please enter a number:"))
Advertisement