import re def checkio(text): text = re.sub('[^a-z]', '', text.lower()) alph = {} for char in text: if char not in alph.keys(): alph[char] = text.count(char) return sorted(alph.items(), key=lambda x: (-x[1], x[0])) if __name__ == '__main__': print( checkio("Hellooaaaacccc bbbbWorld!") )
Standard input is empty
[('a', 4), ('b', 4), ('c', 4), ('l', 3), ('o', 3), ('d', 1), ('e', 1), ('h', 1), ('r', 1), ('w', 1)]