Solution for problem 69 in python.