結果 : how to avoid nested loops python