Please, What is wrong with this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Please, What is wrong with this code?

a = 7 if a % 2 != 0: elif a > 4: print("hi") else: print("bye")

27th Sep 2021, 1:05 AM
Jenkins
1 Answer
+ 5
Hi Jenkins! I think you're trying to make a nested if-else statement. You should start the inner statements with if in a nested statement. So, you can change your elif statement as if instead. Always remember that if and elif statements should be aligned vertically(same block). Similarly, a and outer if statement should be in a same vertical line.
27th Sep 2021, 1:33 AM
Python Learner
Python Learner - avatar