The sample code in Programming in Python3 book