結果 : how to reduce nested for loops in python