Replace main.py

This commit is contained in:
def 2021-12-20 07:45:49 +00:00
parent 3063d6a4c7
commit 7f6ed1cc88
1 changed files with 25 additions and 21 deletions

View File

@ -1,25 +1,29 @@
f = open('lol')
soup = f.read()
data = soup.split()
blacklist = []
unique = []
text = "Вышел зайчик зайчик на крыльцо на крыльцо"
for random_elem in data:
print("Проверяю слово:", random_elem)
if len(random_elem) > 4 and random_elem not in blacklist:
x = 0
for count in data:
x += 1
if count == random_elem and x != 1:
print("Найден дубликат под номером:", data.index(count))
blacklist.append(count) # чтоб больше не проверял это слово
else:
print("Это слово меньше 4 символов или оно уже было проверенно! Пропуск")
words = text.split(' ') # старый
newords = [] #
print(blacklist)
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')