Skip to content
← Back to Community
Python, Syntax Error in elif
Profile icon
DanteChiappino
Voters
Profile icon
SC10TC
Profile icon
coder787878
Profile icon
DanteChiappino
Comments
hotnewtop
Profile icon
ArchieMaclean

Your indentation is wrong - the if..elif..else statements should be aligned, like:

doorgaan = True teRadenGetal=6 while (doorgaan): invoer= input('Kies een getal') if getal < teRadenGetal: doorgaan=true print('Lager') elif (getal > teRadenGetal): doorgaan=true print('Hoger') else: print('Correct')

(Also, you had a ) that shouldn't have been there on line 8. i have removed that above).
Please upvote if this helps :)

Profile icon
DanteChiappino

Thanks guys for helping me out :)

Profile icon
DanteChiappino

Everytime, I try to run it it I get:

Traceback (most recent call last):
File "python", line 8
elif (getal > teRadenGetal)):
^
SyntaxError: invalid syntax

I don't know how to fix it. I hope someone can help me

Profile icon
AllAwesome497

@DanteChiappino he was correct with the intention, but it also must be elif getal < teRadenGetal: not elif (getal < teRadenGetal)):
also

Profile icon
TheDrone7

@AllAwesome497 it doesn't really matter. And in fact they should use those parentheses, it's a good programming habit.

Profile icon
ArchieMaclean

@AllAwesome497 I removed one ) in the code to make it run all right.
I usually have ( ) around if statements just because in some languages it's required so it just makes it consistent.

Profile icon
AllAwesome497

@ArchieMaclean Ah ok. No big deal ;)