[Tutor] Blackjack Betting

Vincent Balmori vincentbalmori at yahoo.com
Sat Jul 2 00:32:10 CEST 2011


I was able to get the program started without errors now. What is left now is
to: 

Having the stash change after winning and losing. No matter what, the value
in stash stays the same. The conditional statement I made which prevents
players with no money from playing is dependent on this.

After each game when I choose to play again, the betting options do not come
up again before the cards are drawn.

Apply the betting option to more than one player the same way each player
can choose to hit. I think the key involves modifying the init function in
class BJ_Game, where it adds the number of players and names.

http://old.nabble.com/file/p31977263/blackjackbetting.py blackjackbetting.py 




Emile van Sebille wrote:
> 
> On 7/1/2011 12:51 AM Andre Engels said...
> 
>> In this case, the error message says:
>>
>> NameError: global name 'bet' is not defined
> 
> Note use of the term global?
> 
>>
>> That means, at some time at the program, it is told to do something with
>> 'bet', but there is no variable bet. And when does that happen? That too
>> is told: at line 124, which says:
>>
>> bet.stash -= bet.wager
>>
>> Go to that line and read your code yourself - what is this 'bet' of
>> which the stash is to be lessened by its wager? Have you told your
>> program that this is the value of the variable 'bet'? Where and how?
> 
> Further, because global is used, it tells you that 'bet' is not in the 
> local scope, nor in the global scope.  Python's general scoping 
> resolution rule is local-global-builtin.  So bet, wherever you think it 
> may be defined, lives in a different namespace.
> 
> See http://docs.python.org/tutorial/classes.html
> 
> Emile
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
> 
> 

-- 
View this message in context: http://old.nabble.com/Blackjack-Betting-tp31966195p31977263.html
Sent from the Python - tutor mailing list archive at Nabble.com.



More information about the Tutor mailing list