题解 | #简单密码#

简单密码

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

strlist = input()
strlist1 = []
dict = {'abc': 2, 'def': 3, 'ghi': 4, 'jkl': 5, 'mno': 6, 'pqrs': 7,
        'tuv': 8, 'wxyz': 9, '0': 0, '1': 1}


for i in range(len(strlist)):
    for key in dict:
        if strlist[i] in key:
            strlist1.append(str(dict[key]))
    
    if(strlist[i].isupper()) & (strlist[i] != 'Z'):
        temp = ord(strlist[i].lower()) + 1
        strlist1.append(chr(temp))
    elif strlist[i] == 'Z':
        strlist1.append('a')
    elif (strlist[i].isdigit()) & (strlist[i] != '1') & (strlist[i] != '0'):
        strlist1.append(strlist[i])

print(''.join(strlist1))
全部评论
前面不是已经判断过‘0’和‘1’了吗,为什么最后一个elif还要剔除这种情况?
点赞 回复 分享
发布于 2023-08-22 19:32 北京

相关推荐

是每个人事都这样与找工作的人这样沟通吗?正常询问不可以吗
据说名字越长别人越关注你的昵称我觉得我要被关注了:excal 我还真不会
点赞 评论 收藏
分享
深夜书店vv:腾讯是这样的,去年很多走廊都加桌子当工区
点赞 评论 收藏
分享
牛客266927136号:为啥实习经历写这么少,项目经历反而大写特写,最重要的还是实习经历吧,写具体点,什么场景下做了什么事,解决了什么问题,优化了什么场景,性能提升了多少多少
点赞 评论 收藏
分享
评论
4
收藏
分享

创作者周榜

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