Chapter 2 code for Dive Into Python 3