+ 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?
2 Answers
+ 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
+ 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.