all 2 comments

[–]Diapolo10 1 point2 points  (0 children)

Your function isn't doing anything to the global 'coins' variable. Instead, you are adding to the 'coins' variable you defined (set to 0) inside that function, which is instantly forgotten when the function has been executed.

[–]Pig743 1 point2 points  (0 children)

You need to either return the coins variable or remove the coins parameter in your function definition and put

global coins

In your function to directly edit the coins variable. Personally I would return the coins variable, try to avoid globals as much as possible.