我正试图编写一个检查程序,但我不知道我在while循环中做了什么错误。有人能帮帮我吗?在
scanPrice
s函数:首先调用readPriceList
函数从文本文件中读取价目表。显示价格字典中的所有项目。然后使用一个循环让客户输入他想要的每件商品的产品代码。每次输入产品代码时,都要检查代码是否在字典中。如果没有,则显示“项目未找到”。如果代码在字典中,则显示“找到的项目”和项目的价格。当客户没有更多的产品代码可输入时,他键入“9999”退出循环。scanPrices
函数将计算、显示并返回所有订购项目的总价。在
def scanPrices():
price_list = readPriceList()
itemCode = 0
totalPrice = 0
while itemCode != 9999:
itemCode = int(input("Enter 4-digit item code [or 9999 to stop]: "))
if itemCode in price_list:
print("Item found. Price:", )
else:
print("Item not found")
totalPrice = totalPrice +
print("Subtotal:$",totalPrice)
return totalPrice
目前没有回答
相关问题 更多 >
编程相关推荐