Jun-08-2017, 04:40 AM
I'm trying to make a simple vending machine program. Running this program gives me this error:
Error:Traceback (most recent call last):
File "C:/Users/ignacio cabero/Desktop/Python/vendingmachine.py", line 13, in <module>
insertp25()
File "C:/Users/ignacio cabero/Desktop/Python/vendingmachine.py", line 11, in insertp25
total_insert += 0.25
UnboundLocalError: local variable 'total_insert' referenced before assignment
global total_cost, total_insert total_cost=0 total_insert=0 float(total_cost) float(total_insert) def insertp25(): total_insert += total_insert + 0.25 print(total_insert) insertp25() insertp25()What can I do? I made the variables global yet nothing seems to work.