import re
def checkio(text):
text = text.lower()
list1 = re.findall(r'[a-zA-Z]',text)
set1 = set(list1)
times = []
for i in set1:
times.append(list1.count(i))
d = dict(zip(set1,times))
d1 = sorted(d.items(),key = lambda x: (-x[1], x[0]))
return d1[0][0]
I finally solved this after i saw the hints.
but i can't figure out the code to sort a dict here :
sorted(d.items(),key = lambda x: (-x[1], x[0]))
could anyone kindly send some explanations or guides to me?
Created at: 2016/03/09 07:52; Updated at: 2019/10/21 08:20