got it!!! finally works! thank you sooo much! this has been a great learning experience.
Now there is another way to look at it, using a list or group of lists for multiple player games.
player_1 = 
player_2 = 
In this case,
money is the local name given to the list we pass in at the time, it could be either of the two players.
would be in the game control loop (a while for the game, a for loop to cycle through the players).
To update the score, we simply append the list with either the positive or the negative value of each win or loss amount.
if player_loses: money.append(-bet) else: money.append(bet)
At each iteration in the player cycle we would check the cumulative sum() of their list to see that it is still in the positive. A negative sum (or aero) would mean they either have to borrow or drop out of the game.
There would be some checking in the game function when a bet is placed as to whether the bet is within the player’s range and would be capped at that amount so the sum could never go into the negative.
Something for down the road. Note that since
money is now a referenced list, we no longer need to declare it as a global. The lists are global, but money is local. Lists and dictionaries do not move around, and the function can update them without any special treatment. They are passed by reference, only.
I wouldn’t. Probably better to have a control loop that can be exited and let it be where the calls are placed.
Here its my code. Hardest part was getting the deck of cards correct but I looked at some of yours code to improve mine. Thanx everyone for sharing, really helpful!
Something to consider that just occurred to me when reading the coin() function.
flip = random.randint(1,2) ... if flip ==1: flip = 'heads' else: flip = 'tails'
What if we do all that in one statement?
flip = ['tails', 'heads'][random.randrange(2)]