PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, October 30, 2022

[FIXED] How to fix unexpected EOF while parsing in python 3.6?

 October 30, 2022     eof, python-3.x     No comments   

Issue

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

Solution

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.



Answered By - andrew_reece
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing