(Python)if语句未执行
因此,如果您输入“Y”,它将执行print(“>>>>>>>>>>>>>>>>>>>>>>>>>>”),但在“if new_user==True:”之后跳过代码的整个主要部分:(Python)if语句未执行,python,Python,因此,如果您输入“Y”,它将执行print(“>>>>>>>>>>>>>>>>>>>>>>>>>>”),但在“if new_user==True:”之后跳过代码的整个主要部分: 我不确定我做错了什么,因为我正在为要执行的if语句正确设置所有参数将第一个if语句更改为if-else梯形图将正确设置“Y”选择值 while has_answered == False: new_choice = input("Are you a new user, (Y) or (N) to choose (
我不确定我做错了什么,因为我正在为要执行的if语句正确设置所有参数将第一个if语句更改为if-else梯形图将正确设置“Y”选择值
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)")
else
仅适用于最近的if
。更改为elif new_choice==“X”
这似乎是一个非常复杂的控制流结构。您最好将循环更改为,而将True
和相应地中断,而不是所有这些控制变量。见:
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