lundi 24 juillet 2017

Why can't input() in Python 3.6 be placed in an if _ is _: statement like this one?

x = str(input("Put 'thing' here \n"))
if x is 'thing':
    print("Success thingx!")
else:
    print(x)

y = str("thing")
if y is 'thing':
    print("Success thingy!")
else:
print(x)

While I expected my result to be

Put 'thing' here 
thing
Success thingx!
Success thingy!

I got the result

Put 'thing' here 
thing
thing
Success thingy!

Is there an error in how I am writing this?

Aucun commentaire:

Enregistrer un commentaire