6개의 로또 숫자를 뽑는 것이므로 조합이고, 중복되는 값이 있으면 안된다. 그래서 start로 범위를 이전보다 다음에서 시작하게 만들어 풀었다. def lotto(idx, start): if idx == 6: print(" ".join(select)) return for i in range(start, k): select[idx] = S[i] lotto(idx+1, i+1) select = [0] * 6 while True: nums = list(input().split()) k, S = int(nums[0]), nums[1:] if k == 0: break lotto(0, 0) print() 풀다보니 이제는 자동적으로 if idx == M : 이런식으로 코드를 작성하게 된다.. 조합과 순열은 결국 많이..