def f(s): return {w: s.split().count(w) for w in set(s.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!