+ 1

a = 12 b = 3 c = 0 print ("a=12,b=3") c = a + b print ("1)c = a + b"),c i=input("1):") print (i,c) print (i==c)

Why the output is false,despite15==15?

6th Oct 2017, 2:00 PM
Antelex
Antelex - avatar
2 Respostas
+ 3
If the input is 15, it is actually the string "15". You have to explicitly convert if from string to integer. i = int(input("1):")) Happy coding! :D
6th Oct 2017, 2:13 PM
LunarCoffee
LunarCoffee - avatar
+ 2
Use Int(): a = 12 b = 3 c = 0 print ("a=12,b=3") c = a + b print ("1)c = a + b"),c i=int(input("1):")) print (i,c) print (i==c) The int() method returns an integer object from any number or string.
6th Oct 2017, 5:37 PM
Rishita
Rishita - avatar