Different results when Try&check pressed
I receive different results with my code. For the same code, most of the time assertion is completed but result is saying error in "One" test. Any clue? Thanks
From: http://www.checkio.org/mission/most-wanted-letter/solve/
HTTP_USER_AGENT:
Mozilla/5.0 (Windows NT 6.2; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0
code follows
def checkio(text): import re from collections import Counter cnt=dict(Counter(re.findall("[a-z]",text.lower()))) lst=cnt.items() srt=sorted(lst,key=lambda k: k[0]) print(srt) srt=sorted(lst,key=lambda k: k[1], reverse=True) print(srt) print(srt[0]) print(srt[0][0]) return srt[0][0] if __name__ == '__main__': #These "asserts" using only for self-checking and not necessary for auto-testing assert checkio("Hello World!") == "l", "Hello test" assert checkio("How do you do?") == "o", "O is most wanted" assert checkio("One") == "e", "All letter only once." assert checkio("Oops!") == "o", "Don't forget about lower case." assert checkio("AAaooo!!!!") == "a", "Only letters." assert checkio("abe") == "a", "The First." print("Start the long test") assert checkio("a" * 9000 + "b" * 1000) == "a", "Long." print("The local tests are done.")