Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

characters_occurrence.py #71

Open
ghost opened this issue Nov 4, 2015 · 0 comments
Open

characters_occurrence.py #71

ghost opened this issue Nov 4, 2015 · 0 comments

Comments

@ghost
Copy link

ghost commented Nov 4, 2015

! /usr/bin/env python3

"""To find the number of times characters are repeated in a string """

from collections import Counter

Counter('abracadabra').most_common(3)

[('a', 5), ('r', 2), ('b', 2)]

The argument of most_common is the number of items to be returned

Default will return count for all characters

Counter('abracadabra').most_common(1)

[('a', 5)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants