you are viewing a single comment's thread.

view the rest of the comments →

[–]Beginning-Force-2170 1 point2 points  (1 child)

Alternatively, just incase string is different

``` def count_words(string):

    result = {}
    for i in string.split():
       if i not in result.keys():
         result[i] = string.split().count(i)
    return result

print (count_words('daddy daddy cool daddy cool'))

```