Clean up the Python code