题解 | #字符串加密#
字符串加密
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))
