First example rewritten in python