Typical "first chapter" problem solved for Python