dimanche 7 février 2021

Can't figure out why my else statement is still calling this function with negative input

I'm teaching myself Python and decided to make a short text-based game, first I decided to make a function for the user to confirm that they in fact do want to play the game with a "yes or no" option, however, even when given the "No" input, the game function is still called. Any help would be greatly appreciated.

This is my command prompt to get into the game:

while i <= 10000000000000000:
    command = input(":")

    if command == "List commands":
        command_list()
        i += 1
    elif command == "Atlas":
        atlas_confirmation()
        i += 1

This is the prompt to confirm the user wants to play the game:

def atlas_confirmation():
    print("Alright, but this one's pretty spooky. Are you sure?")
    yn = input(":")

    if yn == "Yes" or "yes" or "I'm sure" or "Im sure" or "im sure" or "i'm sure":
        atlas_game()
    elif yn == "No" or "no":
        print(command_end)

This is the placeholder for the game:

def atlas_game():
    print(placeholder)
    print(command_end)

When given a positive input, I get the desired output of:

Uh oh! Looks like this code has yet to be completed, but it will be available soon!
Is there anything else I can do for you?
:

However, when I give a negative input, the output is still the same as above ^ as if I'd given a positive input, all instead of the desired output:

Is there anything else I can do for you?
:

I expect my 'if' statement is wrong somewhere but I don't know where or why.

Any help would be greatly appreciated,

thank you.

Aucun commentaire:

Enregistrer un commentaire