Closed
Description
I just saw a solution to the word_count
exercise where my feeling was that this shouldn't pass all tests. There is already one mixed case test, but it has a specific word order so that this solution works.
def word_count(input):
list = {}
for word in input.split():
if word in list:
list[word]+=1
elif word.lower() in list:
list[word.lower()]+=1
else:
list[word]=1
return list
>>> word_count('GO go Go')
{'GO': 1, 'go': 2}
>>> word_count('go Go GO')
{'go': 3}
>>>
Metadata
Metadata
Assignees
Labels
No labels