solution to problem 33 in python