题解 | #简单密码#python3

简单密码

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

fake = input()
true = list(fake)
for i in range(len(fake)):
    if  'a'<= fake[i] <='z':
        if fake[i] in 'abc':
            true[i] = '2'
        if fake[i] in 'def':
            true[i] = '3'
        if fake[i] in 'ghi':
            true[i] = '4'
        if fake[i] in 'jkl':
            true[i] = '5'
        if fake[i] in 'mno':
            true[i] = '6'
        if fake[i] in 'pqrs':
            true[i] = '7'
        if fake[i] in 'tuv':
            true[i] = '8'
        if fake[i] in 'wxyz':
            true[i] = '9'
    elif 'A'<= fake[i] <='Z':
        if fake[i] == 'Z':
            true[i] = 'a'
        else:
            true[i] = chr(ord(fake[i])+32+1)
    else:
        continue
print(''.join(true))
全部评论
最后这个else:后面应该是其他情况 true[i] = fake[i]
点赞 回复 分享
发布于 2022-08-03 06:23
chr返回字符串是大写,应该加个lower就好了
点赞 回复 分享
发布于 2022-04-23 10:11

相关推荐

仁者伍敌:牛子这些人还会点一个自动回复,boss都不带回复的
点赞 评论 收藏
分享
评论
8
13
分享

创作者周榜

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