[29] Solved problem 29 in python