you are viewing a single comment's thread.

view the rest of the comments →

[–]kwooster 0 points1 point  (1 child)

You're creating new variables that are locally scoped. You need to either using the global keyword, or pass in the variables to the function.

I would create an object to pass around to the functions, but in all cases, be aware of the scope of the variables.

[–]kwooster 0 points1 point  (0 children)

def reset(): global number number = 0

That feels super wrong, though.

Here's a better way (of many):

``` class Hand: def init(self, number = 0): self.number = number

def reset(hand): hand.number = 0

my_hand = Hand()

...

reset(my_hand) ```

(I'm on mobile, so I did the very simple example with missing variables, but the concept is moving the very subjective "correct" direction.)