mirror of
https://github.com/Xevion/exercism.git
synced 2026-02-01 02:24:24 -06:00
twelve days and word count exercises
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
import string, re
|
||||
def count_words(sentence):
|
||||
sentence = [x.strip(string.punctuation) for x in [word for word in re.split(r'[_,\s]+', sentence.casefold()) if len(word.strip(string.punctuation + string.whitespace)) >= 1]]
|
||||
return {k : sentence.count(k) for k in list(dict.fromkeys(sentence))}
|
||||
Reference in New Issue
Block a user