31 lines
619 B
Python
31 lines
619 B
Python
def word_count(text):
|
|
result = []
|
|
x = ('абвгдеёжзийклмнопрстуфхцчшщъыьэюя ')
|
|
y = ''
|
|
|
|
for j in text.lower():
|
|
if j in x:
|
|
y += j
|
|
|
|
a = y
|
|
c = list(str(a).split())
|
|
array1 = []
|
|
array2 = []
|
|
for q in c:
|
|
if q in array1:
|
|
index = array1.index(q)
|
|
array2[index] += 1
|
|
else:
|
|
array1.append(q)
|
|
array2.append(1)
|
|
|
|
for i in range(len(array1)):
|
|
result.append((array1[i], array2[i]))
|
|
|
|
return result
|
|
|
|
|
|
f = 'Я пришел, я ушел, я нашел'
|
|
|
|
print(word_count(f))
|