fork download
  1. def f(string): return {word: string.split().count(word) for word in set(string.split())}
  2. print(f("yes yes ok ok "))
Success #stdin #stdout 0.13s 14124KB
stdin
Standard input is empty
stdout
{'yes': 2, 'ok': 2}