Finished problem 41 in python.