题解 | #简单密码#

https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac

while True:
    try:
        ##循环右移
        def shift_left(s):
            shift = 1
            if s >= 'a' and s <= 'z':
                s = ord(s)
                s = ((s+shift)-97)%26+97
                s = chr(s)
            return s
        s = input()
        res = []
        for i in s:
            if i.isdigit():
                res.append(i)
            elif i.isupper() :
                res.append(shift_left(i.lower()))
            else:
                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')
                else:
                    res.append('9')
        print(''.join(res))
    except:
        break


全部评论

相关推荐

能干的三文鱼刷了100道题:公司可能有弄嵌入式需要会画pcb的需求,而且pcb能快速直观看出一个人某方面的实力。看看是否有面试资格。问你问题也能ai出来,pcb这东西能作假概率不高
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务