Question on the Games of Chance exercise (https://www.codecademy.com/practice/projects/games-of-chance):
Has anyone completed this? I’m still on the Heads/Tails function. I can make the function do the basics (take a guess and a bet, perform a random integer/coin flip, then add/subtract the bet from the money pot based on a random coin generator and print the results). However, the bit I’m stuck on is…the instructions also say:
The project also has a variable named money
that starts at 100
. This represents your current amount of money. In every game of chance, you will be able to bet money. The value of money` should change depending on whether you win or lose the game.'
Any ideas on how to do this? I’ve read that you can’t change a variable that exists outside a function (global variable) within a function? i.e. i can use the variable ‘money’ within the function to perform calculations, but I can’t actually change what the value of ‘money’ is outside of the function. Am I missing something here?
Thanks in advance!