当用户输入某些内容时,会发生NameError

2024-07-04 07:47:27 发布

您现在位置:Python中文网/ 问答频道 /正文

你能检查一下我的代码并告诉我为什么NameError:name'Yes'没有定义吗 发生

"""This code prints how many tickets user gets depending on userDollar"""
FirstClassPrice = 44
userDollar = int(input("Please enter the number of dollars you want to 
spend:"))
userDollarConvert = 100 * userDollar
userTick = userDollarConvert // FirstClassPrice

#Input and output of the code showing the change
userChange = userDollarConvert % FirstClassPrice
print("Your Change: $0." + str(userChange))
print("Number of First Class Tickets You Have:" + str(userTick))

#100 Tickets can be changed into 1 dinner ticket
if 100 <= userTick:
  userChoice = input("Would you like to change 100 tickets into a free 
dinner ticket? Yes or No only.")
  if userChoice == ("Yes"):
    DinnerTicket = 100(userTick)
    print("You now have:" + DinnerTicket // userTick + "DinnerTicket(s)")
    print("You have" + DinnerTicket % userTick + "Tickets remaining")

Tags: oftheyouinputcodeyesticketsprint

热门问题