Adding the Python code directly.