def f(string): return {word: string.split().count(word) for word in set(string.split())}print(f("yes yes ok ok "))
Standard input is empty
{'yes': 2, 'ok': 2}
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!