我在我的程序中發現一個錯誤,指出finddiscount()缺少一個必需的位置參數。我似乎無法弄清楚如何正確編碼的查找折扣功能有人可以請幫忙嗎?林肯定這是一個簡單的錯誤,但我是新的python,特別是新功能。謝謝!函數缺少位置參數的錯誤
def finddiscount(discount):
if quantity >= 1 and quantity <= 9:
discount = "0%"
elif quantity >= 10 and quantity <= 19:
discount = "20%"
elif quantity >= 20 and quantity <= 49:
discount = "30%"
elif quantity >= 50 and quantity <= 99:
discount = "40%"
elif quantity >= 100:
discount = "50%"
print (discount)
def main():
quantity = int(input("How many packages where purchased?"))
price = float(input("How much is each item?"))
finddiscount()
return
def finddiscount(quantity):
if quantity >= 1 and quantity <= 9:
discount = "0%"
elif quantity >= 10 and quantity <= 19:
discount = "20%"
elif quantity >= 20 and quantity <= 49:
discount = "30%"
elif quantity >= 50 and quantity <= 99:
discount = "40%"
elif quantity >= 100:
discount = "50%"
print (discount)
main()
以供將來參考,不要試圖去描述錯誤的消息,複製並粘貼實際的消息及其描述和回溯。在這樣一個非常簡單的情況下,人們可能能夠準確地猜出出錯的地方以及在哪裏,但總的來說,錯誤信息中的信息是有用的 - 即使它看起來像希臘文。 – abarnert