想起一道滴滴飞车题:t9字符串匹配,强势转9宫格

'''木有注释'''

t9keyboard = {'2' : 'abc', '3' : 'def', '4' : 'ghi', '5' : 'jkl', '6' : 'mno'  , '7' : 'pqrs', '8' : 'tuv', '9' : 'wxyz'}
str1 = '' a = list(input('please input three numbers: '))
wordlist = list(input('please input the word you want: ')) for i in range(len(a)):
    str1 += t9keyboard[a[i]]



matchcount = 0 max = '0' j = 0 n = 0 wlen = len(wordlist)
matchsort = ['1' for i in range(len(wordlist))] while(wlen > 0): for i in range(len(wordlist[j])): for k in range(len(str1)): if(wordlist[j][i] == str1[k]):
                matchcount = matchcount + 1  matchsort[n] = str(matchcount)
    matchcount = 0  n = n + 1  j = j + 1  wlen = wlen - 1   for i in range(len(matchsort)): if(max < matchsort[i]):
        max = matchsort[i] print('The most matchist word is: ' + wordlist[matchsort.index(max)])





全部评论
这是what排版格式,牛妹在哪里!
点赞 回复 分享
发布于 2017-05-12 19:32

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务