Why The Output is 5 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why The Output is 5

if(2%1-0): print('a' + str(1)) else: print(int('2') + 3)

22nd Mar 2019, 3:09 AM
Luiz Santos
Luiz Santos - avatar
2 Answers
+ 2
Simple. 2%1 - 0 = 0 - 0 = 0 if(0) has converted to if(false) So the else block executed.
22nd Mar 2019, 3:25 AM
Adnan Zawad Toky
Adnan Zawad Toky - avatar
+ 1
Thanks Adnan Zawad Toky
22nd Mar 2019, 3:28 AM
Luiz Santos
Luiz Santos - avatar