- 1

Why this code shows error?! (python3)

Where is the mistake? x = 9 if x < 6: print("number is smaller than 6") else: if x > 10: print("number is bigger than 10") else: if x <= 2: print("the number is smaller or equals to 2") else: if x==9: print("number is 9") else: print("number is 10")

25th Jul 2017, 9:24 PM
Rawen Ghazi
3 Antworten
+ 2
else should be in the same column as it's corresponding if. x = 9 if x < 6: print("number is smaller than 6") else: if x > 10: print("number is bigger than 10") else: if x <= 2: print("the number is smaller or equals to 2") else: if x==9: print("number is 9") else: print("number is 10")
25th Jul 2017, 9:33 PM
God Usopp
God Usopp - avatar
+ 7
your else: are "move"(identation) and don't match with it's corresponding if As @God Usopp point out.
25th Jul 2017, 9:51 PM
AldoS
AldoS - avatar
+ 1
Thank you God Usopp, it worked!
25th Jul 2017, 9:49 PM
Rawen Ghazi