[Tutor] blackJack problem
computer_dude15 at hotmail.com
Wed Oct 24 02:00:19 CEST 2012
> To: tutor at python.org
> From: alan.gauld at btinternet.com
> Date: Tue, 23 Oct 2012 23:46:23 +0100
> Subject: Re: [Tutor] blackJack problem
> Matthew Dalrymple <computer_dude15 at hotmail.com> writes:
> > I thought by having a value outside
> > of the functions made the value global.
> ok...is there an easier way to write this? the reason i was calling that global value the same as the currentBet is because i need to add that value to 5...I have to start at 1000 and if i win add 5 and if i lose subtract 5 and store that value. I have been staring at this stuff for like 3 hours :/ and still cant get even a slight idea as of what should work
> 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...
it should work in theory correct?
> Alan G
> Author of the Learn to Program web site
> Playing with gnus and possibly screwing it up!!
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor