sg_calculator_tkinter_error_check.py

sg_calculator_tkinter_error_check.py If you divide by zero or if you enter a non-numeric value in the “Enter number:” box the program will crash. Try both of these on the previous version and look at the error messages. This version shows how to trap on those messages and provide exception handling code that lets the program keep running using  "try - except".  No new tkinter code in this update but error checking is an important part of writing good code, so this is a useful example. Note CodeSkulptor does not fully support try-except. The code I’ve given you writes an error message to the terminal but that’s not enough. As a student project I suggest you write a short message to the Display text box announcing the error,  and writing something like '*****' to the Result window (or $%!!&$#@!! depending on your mood). For more info on this important topic:

http://docs.python.org/2/library/exceptions.html  a list of built-in exceptions
http://docs.python.org/2/tutorial/errors.html  more info on 'try-except-else-finally'