How to find the count of a word in a string?
<p>I have a string "<code>Hello I am going to I with hello am</code>". I want to find how many times a word occur in the string. Example hello occurs 2 time. I tried this approach that only prints characters - </p>

<pre><code>def countWord(input_string):
    d = {}
    for word in input_string:
        try:
            d[word] += 1
        except:
            d[word] = 1

    for k in d.keys():
        print "%s: %d" % (k, d[k])
print countWord("Hello I am going to I with Hello am")
</code></pre>

<p>I want to learn how to find the word count.</p>
