Adding python version of lecture 24