solved problem 13 in python