【发布时间】:2020-04-23 17:59:14
【问题描述】:
基本上,一旦用户决定根据 RobotQ1 变量输入“YES”,我希望代码重新开始,但是,它会通过 RobotQ2 的第二个用户输入。
restart = "Yes".lower()
while restart == "YES".lower():
print(" In order to obtain the harmonized code of your item answer all the following questions")
print()
print("Q1 : Does your car have 4 wheel drive")
RobotQ1 = input("YES / NO ?:")
if RobotQ1 == "YES".lower():
print("Here is the HS code:...")
restart = input("Do you want to use the application? (Yes / No): ")
if restart =="NO".lower():
print("bye")
break
elif RobotQ1 == "NO".lower():
print("Q2 : Does your Robot have 7 axes ?")
RobotQ2 = input("YES / NO ?:")
if RobotQ2 == "YES".lower():
print("Here is the HS code:....")
restart = input("Do you want to use the application? (Yes / No): ")
if restart =="NO".lower():
print("bye")
break
【问题讨论】:
-
你不也想小写
RobotQ1:if RobotQ1.lower() == "yes":。因为否则,"YES" != "yes"
标签: python python-3.x loops input while-loop