Example code for Chapter 8 of Real Python