该程序应考虑到用户已介绍的所有产品,为我提供了应支付的总金额。问题:创建列表“ Amounts_list”时似乎没有将值添加到列表中。
products_invoice = []
总数= []
def交互():
*#selecting first product/quantity*
code = int(input("add article code: "))
price = {1: 5,2:10,3:15,4:20,5:25,6:30,7:35,8:40,9:45,10:50}
*#article with code 1 costs 5$*
print(f"The price is: {price[code]} $")
quantity = int(input("add quantity: "))
print(f"The total to be paid is: {((price[code])*quantity)} $")
product = code,price[code]*quantity
global products_invoice
products_invoice.append(product)
print(f"products invoice: {products_invoice}") #to debug
product_to_list = list(product) *#converting to a list to be able to extract product[1]*
Amount = product[1]
print(Amount)
global Totals *#creating a new list to add Amount/product[1] which later on I want to add up*
Amounts_list = Totals.append(Amount)
print(Amounts_list) **#I get a None instead of printing the list.**
*#adding up the product[1] amounts/costs of all the introduced articles,to get the grand total.*
Grand_Total = sum(Amounts_list,0)
print(Grand_Total)