[Tutor] blackJack problem
Matthew D
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
> http://www.alan-g.me.uk/
> Playing with gnus and possibly screwing it up!!
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121023/d1dcaa46/attachment.html>
More information about the Tutor
mailing list