先创建一个字典,还有存放加密结果的list
如果是字母,如果是小写,那么遍历key,如果对应上key,就把对应l[i]赋值加密为数字
考虑特殊情况'Z',那么直接对应赋值为'a'
如果是大写,那么编码后+1再解码,再转为小写字母,赋值为l[i]

while True:
    try:
        s = input()
        l = list(s)
        d = {'abc': '2','def':'3','ghi':'4','jkl':'5','mno':'6','pqrs':'7','tuv':'8','wxyz':'9'}
        for i,v in enumerate(s):
            if v.isalpha():
                if v.lower() == v:
                    for k in d.keys():
                        if v in k:
                            l[i] = d[k]
                if v == 'Z':
                    l[i] = 'a'
                    continue
                if v.upper() == v:
                    l[i] = chr(ord(v)+1).lower()
        print(''.join(l))
    except:
        break