0

num = 7 if num == 5: print('Number is 5') elif num == 11: invalid syntax

it appears that my elif statement has an indent problem but my IDLE tells me syntax. suggestions?

4th Nov 2016, 12:48 AM
Douglas Frey
Douglas Frey - avatar
5 ответов
+ 1
I found that it was an indenting issue.
4th Nov 2016, 1:13 AM
Douglas Frey
Douglas Frey - avatar
0
Any time you are using an if/else statement, the following line must be indented. if x == 3: print('correct') elif x == 5: print('also correct') else: print('still correct')
4th Nov 2016, 5:42 AM
Matt Helm
0
not only for elif even for if u have a indent issue. and be careful with statements after elif , as even absence of statements brings out error.
4th Nov 2016, 6:23 AM
aniruddha k
aniruddha k - avatar
0
that is what i found. thank you for your input.
4th Nov 2016, 8:34 AM
Douglas Frey
Douglas Frey - avatar
0
after you write what you wanna print. it doesn't start a new line, so u have to press left arrow to start from the beginning of the line. if num == 5: print("number is 5") else: <-------beginning of a new line
21st Nov 2016, 4:18 PM
Daniel