题解 | #简单密码#

简单密码

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

while True:
    try:
        s=input()
        l=[]
        dic={"abc":'2',"def":'3',"ghi":'4',"jkl":'5',"mno":'6',"pqrs":'7',"tuv":'8',"wxyz":'9'}
        for i in s:
            if i.isdigit():
                l.append(i)
            elif i.isupper():
                if i == 'Z':
                    l.append('a')
                else:
                    l.append(chr(ord(i.lower())+1))
            else:
                for key in dic.keys():
                    if i in key:
                        l.append(dic.get(key))
        print("".join(l))
    except Exception as e:
#         print(e)
        break
全部评论

相关推荐

听说改名字就能收到offer哈:Radis写错了兄弟
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务