+ 1
could someone answer plz Why this code gives no Output?
egg=1 if egg>4: print("hey") if egg==1: print("yay") if egg==6: print("bye")
2 Answers
+ 3
1 is not bigger than 4
+ 1
In this code, top most if statement body contains rest of the code. This happens because of improper indentation. The condition egg>4 evaluates to false that's why the control is not going inside the if block.
Try the following:
#see the indentation carefully
egg=1
if(egg>4):
print("hey")
if(egg==1):
print("yay")
if(egg==6)
print("bye")