On Fri, Jul 1, 2011 at 9:29 AM, Vincent Balmori <vincentbalm...@yahoo.com>wrote:
> > Here is the other one that occurs when I lose > > Traceback (most recent call last): > File > > "/Users/vincentbalmori/Desktop/Python/py3e_source/chapter09/blackjackbetting.py", > line 240, in <module> > main() > File > > "/Users/vincentbalmori/Desktop/Python/py3e_source/chapter09/blackjackbetting.py", > line 236, in main > game.play() > File > > "/Users/vincentbalmori/Desktop/Python/py3e_source/chapter09/blackjackbetting.py", > line 211, in play > player.lose() > File > > "/Users/vincentbalmori/Desktop/Python/py3e_source/chapter09/blackjackbetting.py", > line 124, in lose > bet.stash -= bet.wager > NameError: global name 'bet' is not defined > That error message is really quite expressive, it would much more help you to learn to read it yourself than to run to us every time something goes wrong. The most interesting part of an error message are its last few lines, they say what went wrong, and where it happened. The rest tells you how it got there, which also is important to know sometimes, but many errors can already be solved without looking at it. In this case, the error message says: NameError: global name 'bet' is not defined 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? -- André Engels, andreeng...@gmail.com
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor