题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
"""把密码中出现的小写字母都变成九键键盘对应的数字,如:a 变成 2,x 变成 9. 而密码中出现的大写字母则变成小写之后往后移一位,如:X ,先变成小写,再往后移一位,变成了 y ,例外:Z 往后移是 a 。""" s = input() xin = [] for i in s: if i == "a" or i == "b" or i == "c": xin.append(2) elif i == "d" or i == "e" or i == "f": xin.append(3) elif i == "g" or i == "h" or i == "i": xin.append(4) elif i == "j" or i == "k" or i == "l": xin.append(5) elif i == "m" or i == "n" or i == "o": xin.append(6) elif i == "p" or i == "q" or i == "r" or i == "s": xin.append(7) elif i == "t" or i == "u" or i == "v": xin.append(8) elif i == "w" or i == "x" or i == "y" or i == "z": xin.append(9) elif i.isdigit(): xin.append(i) elif i.isupper(): char = i.lower() tt = chr((ord(char) - ord('a') + 1) % 26 + ord('a')) xin.append(tt) xin2 = ''.join(str(x) for x in xin) print(xin2)