Create codespell.yml (#1698)

* fixup! Format Python code with psf/black push

* Create codespell.yml

* fixup! Format Python code with psf/black push
This commit is contained in:
Christian Clauss
2020-01-18 13:24:33 +01:00
committed by GitHub
parent c01d178798
commit bfcb95b297
78 changed files with 206 additions and 188 deletions

View File

@@ -0,0 +1,23 @@
# Created by sarathkaul on 17/11/19
from collections import defaultdict
def word_occurence(sentence: str) -> dict:
"""
>>> from collections import Counter
>>> SENTENCE = "a b A b c b d b d e f e g e h e i e j e 0"
>>> occurence_dict = word_occurence(SENTENCE)
>>> all(occurence_dict[word] == count for word, count
... in Counter(SENTENCE.split()).items())
True
"""
occurrence = defaultdict(int)
# Creating a dictionary containing count of each word
for word in sentence.split(" "):
occurrence[word] += 1
return occurrence
if __name__ == "__main__":
for word, count in word_occurence("INPUT STRING").items():
print(f"{word}: {count}")