Created
August 24, 2016 19:43
-
-
Save davidejones/cac463724214fc5f7a6c5d46af5e4d4f to your computer and use it in GitHub Desktop.
repeating characters checking
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
| letters = 'aaaabbbbbbbcccddddddddeeeee' | |
| data = {} | |
| for letter in letters: | |
| if letter in data: | |
| data[letter] += 1 | |
| else: | |
| data[letter] = 1 | |
| # which letter has the most repeating chars | |
| l = max(data.iterkeys(), key=lambda k: data[k]) | |
| print(l) | |
| # print out the repeating chars | |
| print(l * data[l]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment