I would like to give some feedback about ...
From: http://www.checkio.org/mission/most-wanted-letter/solve/
HTTP_USER_AGENT:
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36
My Code:
count_dict = {}
text = "one"
def lst_seq(v1, v2):
return map(chr, range(ord(v1), ord(v2)))
for alpha in lst_seq('a', 'z'):
n = 0
for a in text:
if a == alpha:
n += 1
count_dict.update({alpha: n})
print "The most popular letter in the text is - "
print max(count_dict.keys(), key=lambda x: count_dict[x])
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.")
Created at: 2014/09/16 21:59; Updated at: 2016/07/30 13:26