unexpected EOF while parsing

247 views
Skip to first unread message

Ric Findley

unread,
Jun 5, 2018, 10:14:03 AM6/5/18
to spyder
I am new to Python.  I keep getting this errir (unexpected EOF while parsing) when running Spyder.  It happens on conditional statements.  here is an example.
Thanks in advance...

CODE:
num = 100
while not False:
    if num < 0:
        break
print('num is: ' + str(num))

ERRORS:
 [3]: if num < 0:
  File "<ipython-input-3-ae57f3d300c9>", line 1
    if num < 0:
               ^
SyntaxError: unexpected EOF while parsing

break
  File "<ipython-input-4-6aaf1f276005>", line 1
    break
         ^
SyntaxError: 'break' outside loop

rahul kumar

unread,
May 6, 2020, 5:53:45 PM5/6/20
to spyder
The SyntaxError: unexpected EOF while parsing means that the end of your source code was reached before all code blocks were completed. A Python code block starts with a statement like for i in range(100): and requires at least one line afterwards that contains code that should be in it.

Also, this can simply mean you are missing or have too many parenthesis. For example this has too many, and will result in unexpected EOF.
Reply all
Reply to author
Forward
0 new messages