题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
keys = ['1', 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqrs', 'tuv', 'wxyz', '0'] values = list(range(1, 10)) + [0] dic = dict(zip(keys, values)) str1 = input() for i in str1: if i in ''.join(keys): for k, v in dic.items(): if i in k: print(v, end='') elif ord(i) in range(ord('A'), ord('Z')): n = ord(i) + 33 print(chr(n), end='') elif i == 'Z': # 题目中说了Z的后移是a, 下次遇到后移的题时,要想到最后一个后移的情况,需不需要移动的头部 print('a', end='') else: print(i, end='')