diff --git a/HNC/Excercises/04072023 Определить количество каждого слова в строке/main.py b/HNC/Excercises/04072023 Определить количество каждого слова в строке/main.py new file mode 100644 index 0000000..05e82d9 --- /dev/null +++ b/HNC/Excercises/04072023 Определить количество каждого слова в строке/main.py @@ -0,0 +1,18 @@ +def word_count(text): + c = [] + import re + import numpy as np + final = {} + a = re.sub("[^А-Яа-я-A-Z-a-z ]", "", text).lower() + b = str(a).split() + c = list(b) + unique_array, count_array = np.unique(c, return_counts=True) + final = zip(unique_array, count_array) + final2 = list(final) + return final2 + + + +f = 'Я пришел, я ушел, я нашел' + +print(word_count(f))