The updated python code