你能检查一下我的代码,请告诉我为什么NameError:名字'是'没有定义 发生。
"""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")
答案 0 :(得分:0)
在Python 2中,请尝试raw_input()
而不是input()
。它返回一个字符串,而不是尝试将输入作为代码进行评估。