r/programminghelp • u/[deleted] • Feb 25 '21
Python Python Def function help
I'm a relative Python noob, I'm just wondering how I would get the values on the right of the image to increment or decrease depending on weather the number is even instead of the value displayed being -5 or 10. What I hope to be able to do is have the values on the right add up or decrease depending on weather the value produced by the roll is even.
Here is the image: https://imgur.com/ROhw8wU
4
Upvotes
2
u/marko312 Feb 25 '21
This is a problem of local variables - essentially, the
playerscorein the function is a copy which gets destroyed after the function ends.You could
return playerscoresand assign the returned value toplayer1s.