Added a Python solution.