Python code updated