题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
str_ = input() l = list(str_) lr = [] for i in l: if i == '1': lr.append(i) elif i == '0': lr.append(i) elif i in ('a','b','c'): i = '2' lr.append(i) elif i in ('d','e','f'): i = '3' lr.append(i) elif i in ('j','k','l'): i = '5' lr.append(i) elif i in ('g','h','i'): i = '4' lr.append(i) elif i in ('m','n','o'): i = '6' lr.append(i) elif i in ('p','q','r','s'): i = '7' lr.append(i) elif i in ('t','u','v'): i = '8' lr.append(i) elif i in ('w','x','y','z'): i = '9' lr.append(i) elif i.isupper(): if 65 <= ord(i) <= 90: if ord(i) == 90: i = 'a' lr.append(i) else: i = chr(ord(i) + 1).lower() lr.append(i) else: lr.append(i) print(''.join(map(str,lr)))
根据题目算法做判断分支,处理ASCII序数时候字母是从65-90,过90回到a