题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
str1 = input() dic = { 0: [0], 1: [1], 2: ["a", "b", "c"], 3: ["d", "e", "f"], 4: ["g", "h", "i"], 5: ["j", "k", "l"], 6: ["m", "n", "o"], 7: ["p", "q", "r", "s"], 8: ["t", "u", "v"], 9: ["w", "x", "y", "z"], } new_str = "" for i in str1: if 65 <= ord(i) < 90: new_str += chr(ord(i) + 33) elif ord(i) == 90: new_str += "a" elif 97 <= ord(i) <= 122: for k in dic.keys(): if i in dic[k]: new_str += str(k) else: new_str += i print(new_str)