I want to get a number input by the user via input()
and compare it with a specific value, i.e., 3
.
However, I have the impression my if statement doesn't work. The comparison is always False
.
Start = input()
if Start == 3:
print ("successful")
you should check your tabs (I recomend you to use four spaces, not regular tabs and not to mix them)
Some things you could do on your own to get to the root of the problem:
Ways to get to know the type of the object:
Unlike Python 2.x, the function
input()
returns a string object (and does not blindly evaluate the expression provided by the user):This should give an idea how to fix it (compare numbers to numbers).
For further reading:
Python 3 input function returns string.
Try like this
You can also try this as an alternative:
Adding int will convert the variable to int data type.