题解 | #字符串加密#

字符串加密

https://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3

def encrypt(key: str, msg: str):
    abc = "abcdefghijklmnopqrstuvwxyz"
    table = ""
    for ch in key:
        if ch not in table:
            table += ch
    for ch in abc:
        if ch not in table:
            table += ch
    table += table.upper()
    Aa = abc + abc.upper()
    s = ""
    for ch in msg:
        s += table[Aa.find(ch)]
    return s


key = input().split()[0]
msg = input().split()[0]
print(encrypt(key, msg))

全部评论

相关推荐

有气魄的马来熊在摸鱼:我爱vivo 马上换手机 vivo我爱你!!!
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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