Custom Search

Wednesday, March 13, 2013

Python how to use collections counter

>>>
>>>
>>> print Counter("hello")
Counter({'l': 2, 'h': 1, 'e': 1, 'o': 1})
>>>
>>>
>>> print Counter("hheelloo")
Counter({'h': 2, 'e': 2, 'l': 2, 'o': 2})
>>>
>>>
>>> print Counter("saju")
Counter({'a': 1, 's': 1, 'j': 1, 'u': 1})
>>>
>>>

No comments:

Post a Comment