Бутерброд Питон
Я делаю программу магазина сэндвичей.
Я новичок в Python, поэтому мне понадобится немного помощи!
print "Welcome to the sandwich shop!"
name = raw_input("What is your name?")
sandwich = int(raw_input("How many sandwiches do you want?"))
cookie = int(raw_input("How many cookies do you want?"))
mint = int(raw_input("How many mints do you want?"))
sandwich_price = 0.5
cookie_price = 0.05
mint_price = 0.01
print sandwich_price + cookie_price + mint_price
sandwich * sandwich_price = sandwich_price_total
cookie * cookie_price = cookie_price_total
mint * mint_price = mint_price_total
sandwich_price_total + cookie_price_total + mint_price_total = total_order
print ("THe order will be %r dollars!") , total_order
penny = 0.01
nickel = 0.05
dime = 10
quater = 25
dollar = 1
print "Please pay in cash or credit card!"
question1 = raw_input("> ")
if question1 == credit:
print "%r you got %r dollars from your account." % (name, total_order)
if question1 == cash:
print "You paid %r dollars!" % total_order
print "Thank you for coming %r" % name
Я получаю эту ошибку:
1 ответ
Решение
Добро пожаловать в сообщество Python. Ваш код с исправленными ошибками:
print "Welcome to the sandwich shop!"
name = raw_input("What is your name?")
sandwich = int(raw_input("How many sandwiches do you want?"))
cookie = int(raw_input("How many cookies do you want?"))
mint = int(raw_input("How many mints do you want?"))
sandwich_price = 0.5
cookie_price = 0.05
mint_price = 0.01
print str(sandwich_price + cookie_price + mint_price)
sandwich_price_total = sandwich * sandwich_price
cookie_price_total = cookie * cookie_price
mint_price_total = mint * mint_price
total_order = sandwich_price_total + cookie_price_total + mint_price_total
print ("The order will be %r dollars!") , total_order
penny = 0.01
nickel = 0.05
dime = .10
quater = .25
dollar = 1
print "Please pay in cash or credit card!"
question1 = raw_input("> ").lower()#lets you answer Credit as well as credit
if question1 == "credit":
print "%r you got %r dollars from your account." % (name, total_order)
if question1 == "cash":
print "You paid %r dollars!" % total_order
print "Thank you for coming %r" % name
комментарии к основному посту объясняют большинство ошибок.
Найдите минутку и сравните код, чтобы увидеть, что было изменено, чтобы в будущем не повторялись те же ошибки.
и еще раз добро пожаловать!