# -*- coding: utf-8 -*-
from collections import Counter
import itertools, collections
ListeA=['it', 'was', 'the', 'besttttttttttttttrtrtrtrtrttrtr', 'of', 'times', 'it', 'was',
'the', 'worst', 'of', 'times', 'it', 'was', 'the', 'age', 'xx', 'xx', 'xx', 'xx', 'xx', 'xx', 'xx', 'xx', 'xx', 'xx'
'of', 'wisdom', 'it', 'was', 'the', 'age', 'of', 'xx'
'foolishness']
index = collections.defaultdict(list);
for value, key in enumerate(ListeA):
index[key].append(value)
for key1,value1 in index.items():
if len(value1)>=4:
print value1
Ausgabe nicht korrekt. Was ist mein Code Problem. Ausgabe scheintwarum falsches Ergebnis ausdrucken. python enumerate, counter
[0, 6, 12, 27]
[16, 17, 18, 19, 20, 21, 22, 23, 24]
[2, 8, 14, 29]
[1, 7, 13, 28]
I Nummer hinzufügen leicht zu lesen ListeA=[0'it', 1'was', 2'the', 3'besttttttttttttttrtrtrtrtrttrtr', 4'of', 5'times', 6'it', 7'was', 8'the', 9'worst', 10'of', 11'times', 12'it', 13'was', 14'the', 15'age', 16'xx', 17'xx', 18'xx', 19'xx', 20'xx', 21'xx', 22'xx', 23'xx', 24'xx', 25'xx' 26'of', 27'wisdom', 28'it', 29'was', 30'the', 31'age', 32'of', 33'xx' 34'foolishness']
Was ist daran falsch? Sei präzise über die von dir * erwartete * Ausgabe. –