Python Forum
unexpected EOF while parsing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
unexpected EOF while parsing
#1
On executing the script the python prompts for number until the user enters null as an input
def main():
        total = 0 
        number = input('Enter a number : ')
        while number != '':
                total += int(number)
                number = input('Enter a number : ')
        print('Sum of all input number is : ',total)
if __name__=='__main__':
        main()

Error
python sumNumbers.py 
Enter a number : 2
Enter a number : 2
Enter a number : 2
Enter a number : 
Traceback (most recent call last):
  File "sumNumbers.py", line 9, in <module>
    main()
  File "sumNumbers.py", line 6, in main
    number = input('Enter a number : ')
  File "<string>", line 0
    
    ^
SyntaxError: unexpected EOF while parsing
Reply


Messages In This Thread
unexpected EOF while parsing - by whatloop - Mar-09-2019, 02:47 PM
RE: unexpected EOF while parsing - by snippsat - Mar-09-2019, 03:04 PM
RE: unexpected EOF while parsing - by samsonite - Mar-09-2019, 04:34 PM
RE: unexpected EOF while parsing - by whatloop - Mar-09-2019, 06:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  unexpected EOF while parsing dawid294 1 408 Jan-03-2024, 04:22 PM
Last Post: deanhystad
  unexpected EOF while parsing aaron92 3 3,539 Sep-11-2019, 10:01 PM
Last Post: aaron92
  SyntaxError: unexpected EOF while parsing donmerch 2 7,057 Oct-15-2018, 05:12 AM
Last Post: wavic
  unexpected output while parsing file anna 3 3,187 Apr-28-2018, 05:13 PM
Last Post: anna
  Unexpected Output after Running PArsing Script hotsea 7 5,070 Jan-10-2018, 09:55 AM
Last Post: hotsea

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020