Complete Exercise 2 in Chapter 15 of Think Python