if else statement invalid syntax
Title
Question
if num%2 == 0:
...: print('even')
...: else:
...: print('odd')
File "<ipython-input-2-1f320c4e94c2>", line 3
else:
^
SyntaxError: invalid syntax
...: print('even')
...: else:
...: print('odd')
File "<ipython-input-2-1f320c4e94c2>", line 3
else:
^
SyntaxError: invalid syntax
Python-3.4.3 Conditional-Statements 01-02 min 30-40 sec
Answers:
It looks like an indentation error. Make sure that if and else are indented properly before executing the code.
Example:
if num % 2 == 0:
print('event')
else:
print('odd')
More on Python Indentations...
http://net-informations.com/python/err/indentation.htm
Login to add comment