import itertools as it

def add_doublet(t):
    for i in range(len(t)):
        for j in range(i + 1, len(t) + 1):
            yield t[:j] + (t[i],) + t[j:]

def all_doublet_tuples(n):
    for unique_tuple in it.permutations(list(range(n)), n - 1):
        for doublet_tuple in add_doublet(unique_tuple):
            yield doublet_tuple
from pprint import pprint
n = 3
pprint(list(all_doublet_tuples(n)))
Перебрать все списки с одним дубликатом