Complete Exercise 3 in Chapter 4, Section 3 of Think Python