fork download
  1. words = list(map(str ,input().split()))
  2. res = {}
  3. for word in words:
  4. if word not in res:
  5. res[word] = 0
  6. res[word] += 1
  7. print(res)
Success #stdin #stdout 0.13s 14192KB
stdin
cat cat mouse dog dog cat bird
stdout
{'cat': 3, 'mouse': 1, 'dog': 2, 'bird': 1}