add new part of task
This commit is contained in:
parent
74024713b3
commit
cd60369b65
@ -53,3 +53,27 @@ with open ('text.txt', 'r') as text:
|
|||||||
t+=b
|
t+=b
|
||||||
with open ('test.txt', 'w') as text:
|
with open ('test.txt', 'w') as text:
|
||||||
text.write(t)
|
text.write(t)
|
||||||
|
|
||||||
|
# подсчет одинаковых слов и вывод самого большого кол-ва раз
|
||||||
|
list = {}
|
||||||
|
ind = 0
|
||||||
|
len = 0
|
||||||
|
full_list = []
|
||||||
|
num = 0
|
||||||
|
with open ('text.txt', 'r') as text:
|
||||||
|
lines = [line.split() for line in text]
|
||||||
|
for parts in lines:
|
||||||
|
full_list += parts
|
||||||
|
for words in full_list:
|
||||||
|
len +=1
|
||||||
|
if ind != (len+1):
|
||||||
|
if words in full_list:
|
||||||
|
n = full_list.count(words)
|
||||||
|
list[words] = (n)
|
||||||
|
ind+=1
|
||||||
|
it = 0
|
||||||
|
for key, items in list.items():
|
||||||
|
if items > it:
|
||||||
|
it = items
|
||||||
|
it_key = key
|
||||||
|
print (it_key, it)
|
||||||
|
Loading…
Reference in New Issue
Block a user