saving . . . saved if else statement invalid syntax has been deleted. if else statement invalid syntax has been hidden .
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

Python-3.4.3 Conditional-Statements 01-02 min 30-40 sec 28-04-20, 12:38 a.m. grajeshbabu.37@gmail.com

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

28-04-20, 12:48 a.m. iakashchavan


More on Python Indentations...

http://net-informations.com/python/err/indentation.htm


27-07-21, 11:58 a.m. warnerarc


Log-in to answer to this question.