I’ve been trying and failing to create a function that outputs the following from the following inputs:
Input:
print(len(word_counter(["Dog", "Cat", "Dog", "Mouse", "Cat"])))
Output:
3
Input:
result = word_counter(["Dog", "Cat", "Dog", "Mouse", "Cat"])
or
result = sorted(list(result))
print(result)
Output:
['Dog', 'Mouse', 'Cat']
Input:
print(word_counter(["Dog", "Cat", "Dog", "Mouse", "Cat"]).get("Dog"))
Output:
2
Any comments that could even remotely guide me in the right direction would be greatly appreciated. I know that I probably need to use a dictionary and include for- and if-statements somehow.
New contributor
Anonymous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1