Solved problem 11 in python