James Mccannon James Mccannon - 5 months ago 41
Python Question

If Statments on python

What is wrong with this?

passcode = 10

question = raw_input("type code ")

if question == passcode:
print"yey"

wec wec
Answer

You're trying to compare the string "10" to the integer 10. These aren't the same thing. You need to convert the string input to an int with int(). However, you need to be careful that the user only enters integers.

passcode = 10

question = raw_input("type code ")

if int(question) == passcode:
    print "yey"