solved problem 10 in python