Problem 6 solution in Python.
Assert for Problem 6 solution.