Created
August 9, 2021 05:27
-
-
Save aladinoster/ba5dc94854e309e17e0983907b9b13e4 to your computer and use it in GitHub Desktop.
Python: Simple histogram from text or iterables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
if __name__ == "__main__": | |
txt = "This is a vast world you can't traverse world in a day" | |
counts = Counter(txt.split()) | |
print("Here is a sample of counts: ", counts) | |
print("The most common elements are: ", counts.most_common(2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment