728x90 Python1 파이썬(Python) 리스트 모든 조합 구하기 하나의 리스트에서 모든 조합을 구하기 array = [1, 2, 3, 4, 5] from itertools import permutations list(permutations(array, 2)) # [(1, 2), (1, 3), (1, 4), (1, 5), (2, 1), (2, 3), (2, 4), (2, 5), (3, 1), (3, 2), (3, 4), (3, 5), (4, 1), (4, 2), (4, 3), (4, 5), (5, 1), (5, 2), (5, 3), (5, 4)] from itertools import combinations list(combinations(array, 2)) # [(1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3,.. Python 2020. 12. 25. 이전 1 다음 💲 추천 글 728x90