Words Frequency in String Shorthands

 # Using Counter() + split()

from collections import Counter

test_str = 'Python for engineers . Solution for python programs'

print("The original string is : " + str(test_str))

res = Counter(test_str.split())

print("The words frequency : " + str(dict(res)))


No comments: