def userinput():
amount_purchased = input('Enter the amount of bags to be purchased: ')
#The amount entered is compared and the rate of discount is printed
def find_discount(amount_purchased):
amount_purchased = userinput()
if amount_purchased <=25:
discount_rate=0.0
print('The discount rate is 0%')
elif amount_purchased <=50:
discount_rate=0.05
print('The discount rate is 5%')
elif amount_purchased <=99:
discount_rate=0.1
print('The discount rate is 10%')
print('The discount rate is 10%')
嗨,我在尝试从“用户输入”中获取值以显示在功能查找折扣中时遇到问题。如果我让 userinput 成为一个全局变量,我可以让它工作,但我想把它放在一个函数中,这样我就可以改变它在程序中出现的顺序。