-1
while has_answered == False:
    new_choice = input("Are you a new user, (Y) or (N) to choose (X) to end the script and see the class scores")

    if new_choice == "Y":
        new_user = True
        end_script = False
        has_answered = True

    if new_choice == "X":
        end_script = True
        new_user = False
        has_answered = True

    else:
        new_user = False
        end_script = False

if end_script == False:
    print(">>>>>>>>>>>>>>>>>>>>>>>>>")
    if new_user == True:
        player_class = input("Please enter what class you are in (A),(B) or (C)")
        player_name = input("Please enter your name: ")
        questions = 0
        score = 0

        print("You will be tested on your arithmetic abilities with this quiz")
        start_choice = input("Would you like to start the game? (Y)or(N)")

So what would happen is if you entered "Y" it would execute print(">>>>>>>>>>>>>>>>>>>>>>>>>") but skip the whole main part of the code after the "if new_user == True:"

I'm not sure what I am doing wrong as I'm setting all of the parameters correctly for the if statement to be executed

  • 6
    The `else` only aplies to the most recent `if`. change to `elif new_choice == "X"` – Chris_Rands May 20 '20 at 16:02
  • This seems like an awfully complicated structure of control flow. You would be better off changing the loop to a `while True` and `break`ing accordingly rather than all those control variables. see: https://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-response – Tomerikoo May 20 '20 at 16:09

1 Answers1

0

Changing your first if statement as If else ladder will set "Y" choice values properly.

if new_choice == "Y":
    new_user = True
    end_script = False
    has_answered = True
elif new_choice == "X":
    end_script = True
    new_user = False
    has_answered = True
else:
    new_user = False
    end_script = False