【发布时间】:2018-07-11 15:37:04
【问题描述】:
def main():
cash = float(input("How much money: "))
coins = 0
def changeCounter(n):
while True:
if cash - n > 0:
cash -= n
coins += 1
else:
break
return
main()
changeCounter(0.25)
当我运行这段代码时,我得到了错误
UnboundLocalError:赋值前引用了局部变量“cash”
我该如何解决这个问题?
【问题讨论】:
标签: python