Complete Exercise 1 in Chapter 16 of Think Python