Sublime Forum

SyntaxError: unexpected EOF while parsing

#1

hope i’m posting correct here. Using a simple calculator to test sublime3, but i get a parsing error in sublime but program runs fine from the linux terminal. Am using python3 and am building on sublimeREPL, any ideas? thanks!

num1 = float(input('first number: '))
num2 = float(input('second number: '))
oper = input('operator: ')

if oper == ‘+’:
print(num1 + num2)
elif oper == ‘-’:
print(num1 - num2)
elif oper == ‘*’:
print(num1 * num2)
elif oper == ‘/’:
print(num1 / num2)
else:
print(‘bad operator’)

first number: 60
second number: 30
operator: +
Traceback (most recent call last):
File “simple_calculator.py”, line 4, in
oper = input('operator: ')
File “”, line 1
+
^
SyntaxError: unexpected EOF while parsing

Repl Closed

0 Likes

#2

See Build broken? - Python 3 - input()

0 Likes

#3

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.

0 Likes