Hi guys, I'm trying to learn Python. I'm trying to mess around with printing and if then statements. For some reason, whatever number I type in the first box says "I am not 12" (even if I type the number 12. Also, for the second statement, no matter what I put, it will say I am correct. Any help is suggested.
CodePudding user response:
The problem you are having is with your input. when you enter the number 12 it is not returned as a number. it is returned as a string.
If you want to compare your input to the number 12 you need to convert it to a number. 'NUM = int(input("enter your number: "))'
CodePudding user response:
input() takes in a string. You then compare the string against an integer, which will always return False.
To resolve, use int(input()) rather than just input(). (Note that this will break against non-numeric characters.)

