题解 | #简单密码#

简单密码

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

str1 = input()
dic = {
    0: [0],
    1: [1],
    2: ["a", "b", "c"],
    3: ["d", "e", "f"],
    4: ["g", "h", "i"],
    5: ["j", "k", "l"],
    6: ["m", "n", "o"],
    7: ["p", "q", "r", "s"],
    8: ["t", "u", "v"],
    9: ["w", "x", "y", "z"],
}
new_str = ""
for i in str1:
    if 65 <= ord(i) < 90:
        new_str += chr(ord(i) + 33)
    elif ord(i) == 90:
        new_str += "a"
    elif 97 <= ord(i) <= 122:
        for k in dic.keys():  
            if i in dic[k]:
                new_str += str(k)
    else:
        new_str += i
print(new_str)

全部评论

相关推荐

程序员小白条:找的太晚,别人都是大三实习,然后大四秋招春招的,你大四下了才去实习,晚1年
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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