words = list(map(str ,input().split()))res = {}for word in words: if word not in res: res[word] = 0 res[word] += 1print(res)
cat cat mouse dog dog cat bird
{'cat': 3, 'mouse': 1, 'dog': 2, 'bird': 1}
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!