Python solution to 1.