Code that I adapted from the "Violent Python" book