How To Read A Traceback

A LOT of students just ignore this output - that is a *big* mistake as
it is a goldmine of information. Read and benefit from it (yes, it
looks ugly and intimidating, but really isn't).

Here is a typical traceback output (in red in the IDLE shell). Read it
carefully, it will have a lot of useful information for you: What is
causing the problem, and where exactly.

   Traceback (most recent call last):
     File "C:\Documents and Settings\", line 99, in 
     File "C:\Documents and Settings\", line 93, in main
     File "C:\Documents and Settings\", line 70, in calc_tax_total
       return tax
     NameError: global name 'tax' is not defined

Let's take this apart:

The *last line* will show the actual problem that caused the crash:

     NameError: global name 'tax' is not defined

I.e., there is a problem with something named "tax" that was being
used but was not defined - a good guess would be that 'tax' is a
variable of some sort.

In fact, if you look at the line above

     File "C:\Documents and Settings\", line 70, in calc_tax_total
        return tax

you can see that there is a "return tax" statement on line 70 in
method calc_tax_total -- that is a lot of information to pinpoint
where the suspect code is executing.

If you move up the traceback, you will see where each method was in
turn called. So method calc_tax_total was called on line 93 in method
main() and main in turn was called on line 99 in your source

All this information is there for those willing to read it, and should
help you get a fix on your problem.

Aside: In Java there is almost the same mechanism if there is a
       program crash, so reading tracebacks is a useful skill not just
       for Python.