题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
def convert(code): res=[] mystring='abcdefghijklmnopqrstuvwxyza' for i in code: if i.islower(): if i in 'abc': res.append(2) elif i in 'def': res.append(3) elif i in 'ghi': res.append(4) elif i in 'jkl': res.append(5) elif i in 'mno': res.append(6) elif i in 'pqrs': res.append(7) elif i in 'tuv': res.append(8) elif i in 'wxyz': res.append(9) elif i.isupper(): m=mystring.index(i.lower()) res.append(mystring[m+1]) else: res.append(i) return res code=input() print(''.join(str(i) for i in convert(code)))