我如何解决:不能将序列乘以'float'类型的非int(python)

7xllpg7q  于 2022-12-27  发布在  Python
关注(0)|答案(1)|浏览(112)

我只是个python新手,有人能帮我写代码吗?我为这个问题困了一个星期
下面是我代码:

price = {
    "Espresso": 5.80,
    "Americano": 6.90,
}

currency = "$"

print ("welcome coffee machine!\t")
name = input ("can i get your name?\n")

print ("what do you like to order mr/ms " + name + "\n"  )

menu = ("Espresso, Americano")

print (menu)
menu = (input())

quantity = input("How many " + menu + " would you like?\n")
quantity = str(input())

#im stuck at here! T_T 
if menu == "Espresso" :
    price = 5.80
    total = quantity * price
    quantity.append(quantity)
    price.append(price)
    print(total)

elif menu == "Americano":
    price = 6.90
    total = quantity * price
    quantity.append(quantity)
    price.append(price)
    print(total)

else:
     menu()

#invoice receipt

print("Thank you for order " + name + ", please wait your " + menu + " at counter\n")

希望某人/某人能帮我解决这个问题

k97glaaz

k97glaaz1#

由于此行,您将收到错误:

quantity = str(input())
price = 5.80
total = quantity * price

你要用string乘以float

TypeError: can't multiply sequence by non-int of type 'float'

相关问题