I have a string \"Hello I am going to I with hello am\". I want to find how many times a word occur in the string. Example hello occurs 2 time. I tried this app
Hello I am going to I with hello am
If you want to find the count of an individual word, just use count:
count
input_string.count("Hello")
Use collections.Counter and split() to tally up all the words:
collections.Counter
split()
from collections import Counter words = input_string.split() wordCount = Counter(words)