Created
February 27, 2013 13:01
-
-
Save rahul8590/5047746 to your computer and use it in GitHub Desktop.
If you want a dictonary consisting of repeating characters only for a given string in python.
This file contains 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
# To get a dictionary of repeated characters in a given string | |
some_dict = {} | |
for i,c in enumerate("testing"): | |
some_dict[c] = some_dict.get(c,0) + 1 | |
some_dict = {key: value for key, value in some_dict.items() if value != 1} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment