Okay. I am creating a program for school and I am a beginner to python. Here is my code:

intro = input("Want to play a game of number guess? ")

    while intro == 'yes':
        print("\nOkay. Just guess the number I am thinking of from 1 to 10.)
        if intro != 'yes' or 'no':
            print("\nThat command is not in my program. Try again: ")
            intro = input()  #This is supposed to let you retype your answer to the question if you did not type in no or yes
        if intro == 'no':
            choice = exit()  

    slot = input("\nInsert 50 cents into the coin slot to start. ")
    while slot != 'insert coin' or 'insert' or 'insert coins':
        print("What are you trying to do? Try again: ")
        slot = input()
        if slot  == 'insert':
            print("What are you inserting?")
            slot = input()
        if slot == 'insert coin':
            print("Quit trying to nickle and dime me! \nTWO coins (two quarters = 50 cents - duh)")
            slot = input()
        if slot == 'insert coins':
            print("\a\a\aBING BING BING!! Thank you for playing Jessica's Number \nGame. We will start in: \n3")
            print("2")
            print("1")
            print("....GO!! \nYou have: ", points,"points")


    guess = int(input("\nEnter your guess: "))

So what I need help with is that when I type in a wrong answer to the yes or no question in the beginning it's supposed to let you know that you have to write yes or no and it lets you type it in until you get it right and when you type yes or no the program restarts all over again and wont go to the next section. Can someone help me with this? (sorry i didn't know how to explain it well)

Use a while() loop that checks for the answer. Also, you should print what options are available as an answer instead of making the enterer guess. This is not intended as a complete answer.

while intro not in ["yes", "no"]:
    intro = input("Want to play a game of number guess? ('yes' or 'no'")

available_guesses = [str(x) for x in range(1, 11)]
while intro == 'yes':
    guess = "0"
    while guess not in available guesses:
        guess = input("\nOkay. Just guess the number I am thinking of from 1 to 10. ")
    while intro not in ["yes", "no"]:
        intro = input("Want to play a game of number guess? ('yes' or 'no'")

(sorry i didn't know how to explain it well)

That is why you can't code it. You have to first explain it in words, in detail, in order to explain it in code?

Edited 5 Years Ago by woooee: n/a

This question has already been answered. Start a new discussion instead.