結果 : how to refactor python code