0

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")  

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

You're welcome. If this answer resolved your issue, please marked it accepted by clicking the check box to the left of the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.