Apr-11-2019, 09:34 PM
Another way is to use closure 'creatively' to reference the money (not that I recommend such a practice; changing value in global namespace from within function makes debugging real pain):
>>> money = [4000] >>> def blacksmith(): ... money[0] -= 300 ... print('you bought a sword') ... >>> def oldwitch(): ... money[0] -= 700 ... print('you bought a potion') ... >>> blacksmith() you bought a sword >>> money[0] 3700 >>> oldwitch() you bought a potion >>> money[0] 3000
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.