could someone answer plz Why this code gives no Output? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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")

8th Dec 2018, 9:09 AM
RiGeL
RiGeL - avatar
2 Answers
+ 3
1 is not bigger than 4
8th Dec 2018, 9:30 AM
TurtleShell
TurtleShell - avatar
+ 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")
8th Dec 2018, 6:47 PM
Rishi Anand
Rishi Anand - avatar