final python code