0
私の出力の重要な部分は、finalList
の長さを識別することが、どこかに私のコードでは、重複が削除されることができることであり、私は私のコードで重複が削除されていますか?
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 >= 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)
OUTPUT
[('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'c'), ('c', 'a'), ('c', 'b')]
を把握することはできません
私はそれが重複を削除していることを知っている、またはおそらく私のコードが何かを完全に欠落している私の出力から[('a','a'), ('b','b'), ('c','c')]
ここでは:['permutations'](https://docs.python.org/2/library/itertools.html#itertools.permutations)? – zvone
はあなたの他のブロックがインデントされているはずですか? – kpie
私は文書を読んでいます – oneman