Why does an input of 5 give 0No | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
19th Feb 2022, 5:11 AM
Goodness Ogunlana
2 Answers
+ 3
Hi, Goodness Ogunlana! Because what you gives as argument to the input function ( x = input(int()) ) become a promt for input. And you gave int() as a argument to the input function, which return 0. This is a bit tricky to see in SoloLearns app, when you make your inputs in a box. So input promts first 0, and then you inputed 5. But 5 is not converted to an integer; it’s still a string, so your if statements condition (if x == 5:) becomes False and it prints ”No”. So it becoms: 0No
19th Feb 2022, 6:41 AM
Per Bratthammar
Per Bratthammar - avatar
+ 2
x = int(input())
19th Feb 2022, 5:14 AM
NEZ
NEZ - avatar