Game of chance

Hey, I’m new here and just did the topic functions in Python and now I’m at game of chances. But I just don’t know why that doesn’t work.

I gave the value money before the function and now I want to add / subtrair the new value of bet, but there is always an error. Did I set the operators wrong?

And how do I manage to maintain the value the second time I play, so when I start with 100 and play with 110 the second time. How do I do that?

Your program defines money as a global variable, but the function doesn’t see it when you go to set it. That’s because we cannot set globals inside a function without declaring a binding to them.

global money

That will be the first line of the function code block.

1 Like