An exercise from learning Python