题解 | #简单密码#

简单密码

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

pw = input()
l2 = [
    ["a", "b", "c"],
    ["d", "e", "f"],
    ["g", "h", "i"],
    ["j", "k", "l"],
    ["m", "n", "o"],
    ["p", "q", "r", "s"],
    ["t", "u", "v"],
    ["w", "x", "y", "z"],
]
s = ""
for each in pw:
    if each.isupper():
        if each == "Z":  # 如果是Z直接替换更方便
            s += "a"
        else:
            s += chr(ord(each) + 1).lower()  # 通过ASCII码加一位来找到下一个字母
    elif each.islower():
        for num in l2:
            if each in num:
                s += str(l2.index(num) + 2)  # 利用索引
    else:
        s += each
print(s)

全部评论

相关推荐

07-02 13:52
武汉大学 golang
骗你的不露头也秒
牛客87776816...:😃查看图片
点赞 评论 收藏
分享
05-23 19:02
吉林大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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