Title: give you a text containing different English letters and punctuation, you want to find the most important letters, the letters returned must be lowercase, when checking the most wanted letters, is not case-sensitive, so in your search "a" == "a". Make sure you don't count punctuation, numbers and spaces, only the letters. If you find two or more than two letters with the same frequency, return the letters that appear first in the alphabet. For example "one" contains "O", "n", "E" each letter at a time, so we select "E". Test data: hello world! How do you do? oneoops! AAAOOO!!!! Abe correct result: LOEOAA problem-solving ideas: First Delete non-alphabetic characters and all the letters into lowercase, and then count the word frequency of each letter, and then find the corresponding letter according to the maximum word frequency, the result may be more than, it is OK, the order is good, and finally the first value of the list after sorting out. Script: Import redef checkio (text): text = re.sub (R ' [^a-zA-Z] ', ', text.lower ()) mydict = {} for letter In set (text): mydict[letter] = text.count (letter ) mylist = [] for each_item in Mydict.keys (): if mydict[each_item] == max ( Mydict.values ()): mylist.append (Each_item) mylist.sort ()  RETURN MYLIST[0]
This article is from the "Last Night Stars" blog, please make sure to keep this source http://yestreenstars.blog.51cto.com/1836303/1661643
Find the letters with the highest frequency