30 lines
641 B
Python
30 lines
641 B
Python
|
unique = []
|
||
|
text = "Вышел зайчик зайчик на крыльцо на крыльцо"
|
||
|
|
||
|
|
||
|
words = text.split(' ') # старый
|
||
|
newords = [] #
|
||
|
|
||
|
|
||
|
|
||
|
count = 0
|
||
|
print('\nStart words list:\n', words, '\n')
|
||
|
|
||
|
|
||
|
for w in words:
|
||
|
if w in unique and len(w) > 4:
|
||
|
count += 1
|
||
|
#print(f'Слово {w} повторяется, позиция:', words.index(w))
|
||
|
ind = words.index(w)
|
||
|
print(f'Clone: {w} / index:', ind)
|
||
|
#newords.insert(ind, count)
|
||
|
newords.append(count)
|
||
|
|
||
|
|
||
|
|
||
|
else:
|
||
|
unique.append(w)
|
||
|
newords.append(w)
|
||
|
|
||
|
print('\nNew words list:\n', newords, '\n')
|