l=['apple', 'orrange','apple', 'orrange','banana'] from collections import Counter print(Counter(l))
Standard input is empty
Counter({'orrange': 2, 'apple': 2, 'banana': 1})
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!