Write a function which returns the count of each token in a given sentence as a dictionary


Topic: Write a function which returns the count of each token in a given sentence as a dictionary

Solution

from collections import Counter
def count_tokens(sent):
    sent = list(sent)
    return dict(Counter(sent))



List all Python Programs