I have the following
if('y' == input("Enter y to continue")):
# do something
But it doesn't work, no matter what I type?
I have the following
if('y' == input("Enter y to continue")):
# do something
But it doesn't work, no matter what I type?
This is a known bug on windows, you can identify it by doing print(repr(input("put y: "))
Try this
input("put y:").strip().lower() == "y"
I can't reproduce this here:
>>> if('y' == input("Enter y to continue: ")):
... print("Yeah!")
...
Enter y to continue: y
Yeah!
>>>
But I would do it differently anyway:
answer = input("Enter y to continue: ")
if answer.lower().startswith("y"):
print("Yeah!")
also handles Y, Yes!, yes, please... etc. correctly.