2017-06-22 8 views
0

私のコードを確認できますか?なぜ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") 
+0

3行目と17行目は、2行目の文章が長すぎて質問バーに収まりきれなかったためです。 –

+0

Python 2を使用しているので、 'raw_input'を使用しているはずです。 Python 2の 'input'' eval'はユーザが入力した文字列です。エラーが発生します。 –

+0

彼はprint with()を使っていますので、python3ではありません。python2 –

答えて

0

のPython 2では、raw_input()代わりのinput()してみてください。コードとして入力を評価しようとするのではなく、文字列を返します。

関連する問題