I wrote this very simple code, it doesn't work and I can't understand why. I answer 'good' but if part doesn't work!
def howdy ():
p = input("how's it going?")
if p is "good":
print("Cheers")
howdy()
I wrote this very simple code, it doesn't work and I can't understand why. I answer 'good' but if part doesn't work!
def howdy ():
p = input("how's it going?")
if p is "good":
print("Cheers")
howdy()
You have to use:
If p == 'good':
The ==
compares the value of the two. The Is
keyword checks for identity by comparing the memory address.
Hope this explains it enough. Hannes
have you tried
if p == "good":
the double equal means the same as. Also, if you are looking for a helpful free beginner course, try codecademy. They helped me loads learn python