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.
2021-12-20 07:45:49 +00:00
|
|
|
unique = []
|
|
|
|
text = "Вышел зайчик зайчик на крыльцо на крыльцо"
|
2021-12-05 23:21:17 +00:00
|
|
|
|
|
|
|
|
2021-12-20 07:45:49 +00:00
|
|
|
words = text.split(' ') # старый
|
|
|
|
newords = [] #
|
2021-12-05 23:21:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-12-20 07:45:49 +00:00
|
|
|
count = 0
|
|
|
|
print('\nStart words list:\n', words, '\n')
|
2021-12-05 23:21:17 +00:00
|
|
|
|
|
|
|
|
2021-12-20 07:45:49 +00:00
|
|
|
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)
|
|
|
|
|
2021-12-05 23:21:17 +00:00
|
|
|
|
2021-12-20 07:45:49 +00:00
|
|
|
|
|
|
|
else:
|
|
|
|
unique.append(w)
|
|
|
|
newords.append(w)
|
2021-12-05 23:21:17 +00:00
|
|
|
|
2021-12-20 07:45:49 +00:00
|
|
|
print('\nNew words list:\n', newords, '\n')
|