[python] Return outside function error in Python