Reputation: 9
Im getting the EOF at the end of the program when i try to run it. i dont really know how to fix it. at first i was getting "if" as an invalid syntax but i think i was able to fix that. thanks for the help
while True:
try:
print("Do you want to enter a number?")
print("y - yes")
print("n - no")
choice = int(input("Enter here: "))
if choice == y:
print("")
count = number
for indice in range(1,number + 1, 1):
print(number + indice)
print("")
print("All done")
Upvotes: 0
Views: 14513
Reputation: 21274
You're missing a except
to match try
.
Note that there are other issues with your code that will break it, even once you've added except
. For example,
if choice == y:
...
This should be 'y'
instead of y
. As it is, y
is expected to be a variable, but you're looking to match on the user input 'y'
or 'n'
.
Also, if you want a string input, then:
choice = int(input("Enter here: "))
will throw an error if you enter, say, 'y'
:
invalid literal for int() with base 10: 'y'
Try taking things one line at a time and making sure you understand what's supposed to happen at each point, and test it. Then put them together.
Upvotes: 1