题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
line = input() d = {"abc": 2, "def": 3, "ghi": 4, "jkl": 5, "mno": 6, "pqrs": 7, "tuv": 8, "wxyz": 9} ans = "" for ch in line: if ch.isdigit(): ans += ch elif ch.isupper(): # 密码中出现的大写字母则变成小写之后往后移一位 ans += chr(ord("a") + (ord(ch.lower()) + 1 - ord("a")) % 26) else: for key in d: if ch in key: ans += str(d[key]) print(ans)