結果 : how to optimize nested for loops in python