could somebody explain to me how this has no out put | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

could somebody explain to me how this has no out put

if 15 == 30: print ("number is 30") if 15 > 16: print ("number is greater than 16") if 15 == 15: print ("number is 15") print ("program ended")

18th Dec 2018, 7:24 AM
GackedPeach
GackedPeach - avatar
2 Answers
+ 1
Well, it has some output. Namely "program ended". Nothing else is printed, because the first condition 15==30 is wrong. Therefore the if-block is not entered, neither are the nested ifs If there would be no indent (no nested, but separate ifs), it would also print "number is 15"
18th Dec 2018, 7:39 AM
Matthias
Matthias - avatar
+ 1
thanks heaps but worked that out right after i posted that lol its blindingly obvious to me now
18th Dec 2018, 7:49 AM
GackedPeach
GackedPeach - avatar