finished problem 6 in Python!