题解 | #简单密码#

简单密码

http://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac

import string

u = string.ascii_uppercase
l = string.ascii_lowercase
t = str.maketrans(u,l[1:]+l[0])
d = {"abc":2,"def":3,"ghi":4,"jkl":5,"mno":6,"pqrs":7,"tuv":8,"wxyz":9}
ll=[]
while True:
    try:
        s = input()
        for i in s:
            if i in u:
                j = i.translate(t)
                ll.append(j)
            elif i in l:
                for k in d.keys():
                    if i in k:
                        j = str(d[k])
                        ll.append(j)
            else:
                ll.append(i)
        print(''.join(ll))
    except:
        break
全部评论

相关推荐

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