Python: Total number of words in a sentence (#194)
parent
8d5cae05ff
commit
333a2facea
|
@ -0,0 +1,10 @@
|
|||
def word_count(s: str) -> int:
|
||||
return len(s.lower().split())
|
||||
|
||||
|
||||
def unique_word_count(s: str) -> int:
|
||||
return len(set(s.lower().split()))
|
||||
|
||||
|
||||
for s in ("The Matrix", "To Be or Not to Be", "Kiss Kiss Bang Bang"):
|
||||
print(s, word_count(s), unique_word_count(s))
|
Loading…
Reference in New Issue