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)")
所以会发生什么,如果您输入“ Y”,它将执行print(“ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>”),但跳过“ if new_user == True:”之后的整个代码的主要部分
我不确定我在做什么错,因为我为要执行的if语句正确设置了所有参数
答案 0 :(得分:0)
将第一个if语句更改为If else阶梯,将正确设置“ Y”选择值。
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