SyntaxError: unexpected EOF while parsing


Question

I have no idea why this does not work please help

import random
x = 0
z = input('?')
int(z)

def main():
    while x < z:
        n1 = random.randrange(1,3)
        n2 = random.randrange(1,3)
        t1 = n1+n2
        print('{0}+{1}={2}'.format(n1,n2,t1)

When i run this it outputs this error

File "/Users/macbook/Documents/workspace/gamlir_filar/samlagning.py", line 12

                                                ^
SyntaxError: unexpected EOF while parsing

I am using eclipse and python 3.3 and i have no idea why this happens. It sometimes outputs errors like this.

1
20
7/18/2014 5:33:39 PM

You're missing a closing parenthesis ) in print():

print('{0}+{1}={2}'.format(n1,n2,t1))

and you're also not storing the returned value from int(), so z is still a string.

z = input('?')
z = int(z)

or simply:

z = int(input('?'))
33
5/1/2013 10:25:12 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon