- 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")
3 Réponses
+ 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")
+ 7
your else: are "move"(identation) and don't match with it's corresponding if
As @God Usopp point out.
+ 1
Thank you God Usopp, it worked!