u4
This commit is contained in:
parent
d9fa93a26c
commit
0e1ca921d6
@ -1,6 +1,6 @@
|
|||||||
def count_words(sentence):
|
def count_words(sentence):
|
||||||
dict = {}
|
dict = {}
|
||||||
separators = [".", ",", ":", "!", "?", "\n", "\t", "'", " "]
|
separators = [".", ",", ":", "!", "?", "\n", "\t", "'", " ", '"']
|
||||||
|
|
||||||
previous_i = 0
|
previous_i = 0
|
||||||
for i, chr in enumerate(sentence):
|
for i, chr in enumerate(sentence):
|
||||||
@ -11,9 +11,9 @@ def count_words(sentence):
|
|||||||
if word in separators or word == "":
|
if word in separators or word == "":
|
||||||
continue
|
continue
|
||||||
if word in dict:
|
if word in dict:
|
||||||
print(dict)
|
|
||||||
dict[word] = dict[word] + 1
|
dict[word] = dict[word] + 1
|
||||||
print(dict)
|
|
||||||
else:
|
else:
|
||||||
dict.update({word : 1})
|
dict.update({word : 1})
|
||||||
return dict
|
return dict
|
||||||
|
|
||||||
|
print(count_words("""To je heslo: 'HESLO 123'!", zvolala postava zo seriálu Panelák.\nPotom som utiekol."""))
|
||||||
Loading…
Reference in New Issue
Block a user