Add answer for problem 1 in Python