mercredi 30 décembre 2020

Why aren't my if statements working? Not reading the input right

I have been struggling with this problem, when I make a few if and elif statements, and when I go to type the input, it does not register my input, it shows me the wrong output. Here is my code.

def startup():
    print("Hello! Thank you for playing my game!")
    time.sleep(1)
    print("If you want to start then type 'start'.")
    time.sleep(1)
    print("If you want to exit the game then type 'exit'.")
    time.sleep(1)
    print("If you want to see the about then type 'about'.")
    time.sleep(0.5)
    while True:
        choice = input("Type an option: ")
        if choice == "start" or "Start":
            print("Ok, starting...")
            time.sleep(1)
            break
        elif choice == "exit" or "Exit":
            exit_question = input("Are you sure? Type Y or n.")
            if exit_question == Y:
                print("Exiting...")
                break
            else:
                print("Ok sorry...")
        elif choice == "about" or "About":
            about = open("about.txt", "r")

Then when I run the code this is what I get.

Hello! Thank you for playing my game!

If you want to start then type 'start'.

If you want to exit the game then type 'exit'.

If you want to see the about then type 'about'.

Type an option: about   <--------- my input

Ok, starting...

If anyone is able to help then that would be great.

Thanks, Noah

Aucun commentaire:

Enregistrer un commentaire