I have a while loop that works as I want it to. However when I change a variable from 'Yes' to 'Yes' or 'yes' or 'Y' or 'y' it no longer works properly.
The main parts of the code are:
loop = 'Yes'
while loop == 'Yes':
then I have some defs. Then:
loop = input("Shall we begin?")
if loop == 'Yes':
print("some text")
response = input("What is your answer?")
if response == 'Yes':
response = loop
print("some other text")
else:
response = loop
print("some other text")
else:
print("Exit")
time.sleep(5)
sys.exit(0)
else:
print("Exit")
time.sleep(5)
sys.exit(0)
What I want to happen is for the first input, if the person answers Yes, yes, Y or y, the game will print out some text and continue. If they answer anything else it will exit.
If the first answer is Yes or etc... the game will print some text and ask if them to answer a question. For this question, it does not matter what they answer, the game will print out the same response.
Then we go back to the start where it asks them if they want to continue.
This all works fine when I set the answer to == 'Yes'
However if I change this to == 'Yes' or 'yes' or 'Y' or 'y' it no longer works properly.
What am I doing wrong? Many thanks.