想起一道滴滴飞车题: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

相关推荐

07-02 13:52
武汉大学 golang
骗你的不露头也秒
牛客87776816...:😃查看图片
点赞 评论 收藏
分享
下个早班:秒挂就是不缺人
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务