Compare commits

...

2 Commits

Author SHA1 Message Date
Marege
cff2503cc0 U4 2026-10-06 14:38:33 +02:00
Marege
27e56c0e79 U4 2026-10-06 14:38:10 +02:00

18
u4/word_count.py Normal file
View File

@ -0,0 +1,18 @@
def count_words(sentence):
cleand = ""
for i in sentence: #чистим від значків
if i.isalnum():
cleand += i
else:
cleand += ""
cleaned = cleand.split() # пакуєм в ліст
result = {}
for word in cleaned:
if word in result: # дивимся чи є якщо є то пропускаєм
continue
count = 0
for currentword in cleaned:#дивимся чи є в інших таке якщо є то +
if currentword == word:
count += 1
result[word] = count
return result