python code train