Updated Python solution to problem 62