[Tutor] blackJack problem

Alan Gauld alan.gauld at btinternet.com
Wed Oct 24 00:46:23 CEST 2012


Matthew Dalrymple <computer_dude15 at hotmail.com> writes:

> I thought by having a value outside
> of the functions made the value global. 

Not quite.
To change the global value in a function you also need to declare it as
global inside the function. Otherwise it will create a new local
variable that has no effect on the global one.

Also by declaring a parameter of your function with the same name as the
global you confuse things. Don't do that.


Am i somewhat on the right track?
>  
> any help would be appriciated...
>  
> Oh i also forgot to mention that even though im not using all the parameters
> they have to be there because the professor wants to be able to run other
> peoples "player1.py" files on my game.

Interesting concept. And if the other peoples files are calling your
functions with values in those parameters you will just ignore them I
presume? Hmmm, that should produce some interesting results...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
Playing with gnus and possibly screwing it up!!



More information about the Tutor mailing list