Created
February 2, 2018 01:58
-
-
Save Everfighting/d046a99d55956a77234569efd8fa7c9b to your computer and use it in GitHub Desktop.
count the every character in string
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
| >>> string = 'hello world' | |
| >>> { a:string.count(a) for a in set(string.replace(' ','')) } | |
| {'h': 1, 'e': 1, 'w': 1, 'l': 3, 'o': 2, 'd': 1, 'r': 1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment