SyntaxError: unexpected EOF while parsing
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('?'))
Maybe this is what you mean to do:
import random
x = 0
z = input('Please Enter an integer: ')
z = int(z) # you need to capture the result of the expressioin: int(z) and assign it backk to z
def main():
for i in range(x,z):
n1 = random.randrange(1,3)
n2 = random.randrange(1,3)
t1 = n1+n2
print('{0}+{1}={2}'.format(n1,n2,t1))
main()
- do z = int(z)
- Add the missing closing parenthesis on the last line of code in your listing.
- And have a for-loop that will iterate from x to z-1
Here's a link on the range() function: http://docs.python.org/release/1.5.1p1/tut/range.html