This repository has been archived on 2022-09-12. You can view files and clone it, but cannot push or open issues or pull requests.
b-content/other/main.py

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')