[Tutor] Umm.. I need help on changing Global Variables.
alan.gauld at btinternet.com
Thu Jan 29 23:26:11 CET 2015
On 29/01/15 17:16, Tallen Grey Smith wrote:
> def game():
> global level
> global player_health
> global enemy_health
> global steps
> global civilians
> global charge
This is fine.
But it only tells this function to treat them as globals.
> def charge_1():
This does nothing useful.
You need to tell the function that they are global just as
you did above. Global variables are considered bad practice
so Python doesn't make it easy to use them. (Although a
lot easier than some languages)
There are quite a few other things we could comment on in your
code but this should resolve the immediate issue.
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:
More information about the Tutor