题解 | #简单密码#
简单密码
http://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
- 暴力解法优化:根据小写字母的相对位置(index)获取相应数字
d = "22233344455566677778889999"
def change(s):
if s.isdigit():
return s
if s.isupper() and s != "Z":
return chr(ord(s) + 1).lower()
elif s == "Z":
return "a"
if "a" <= s <="z":
return d[ord(s) - ord("a")]
print("".join([change(i) for i in input()]))