Complete Exercise 3 in Chapter 15 of Think Python