pyo3/examples/word-count/word_count/__init__.py

14 lines
323 B
Python
Raw Normal View History

from .word_count import search, search_sequential
__all__ = ["search_py", "search", "search_sequential"]
2020-06-05 12:33:15 +00:00
def search_py(contents, needle):
total = 0
2020-06-05 12:33:15 +00:00
for line in contents.split():
words = line.split(" ")
for word in words:
if word == needle:
total += 1
return total