Problem 8, Python