Where in my code are duplicates being deleted?
<p>An important part of my output is being able to identify the length of the <code>finalList</code> but somewhere in my code, duplicates are being deleted and I can't figure out where</p>

<pre><code>from itertools import chain, permutations
allPos = []
first_list = ['a','b','c']
match_list = [['a','b','c'], ['a','b','c']]

for i in range(1,30):
    for phrase in permutations(first_list, i):
        for ind, letter in enumerate(chain.from_iterable(phrase)):
             if ind &gt;= len(match_list) or letter not in match_list[ind]:
                break
        else:
            allPos.append(phrase)

finalList = []

for i in allPos:
    if len(i) == len(allPos[-1]):
        finalList.append(i)

print(finalList)
</code></pre>

<p>OUTPUT</p>

<pre><code>[('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'c'), ('c', 'a'), ('c', 'b')]
</code></pre>

<p>I know that it is deleting duplicates, or perhaps my code is just missing something completely because I am missing <code>[('a','a'), ('b','b'), ('c','c')]</code> from my output</p>

<p>You can try with this. Change <code>iterable</code> using permutations.</p>

<pre><code>from itertools import chain, permutations
...
...
for i in range(1,30):
    # change iterable
    for phrase in permutations([j for ele in match_list for j in ele], i):

...
for i in set(allPos):
    if len(i) == len(allPos[-1]):
        finalList.append(i)

print (sorted(finalList))
[('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'b'), ('b', 'c'), ('c', 'a'), ('c', 'b'), ('c', 'c')]
</code></pre>

python permutation