题解 | #字符串加密#
字符串加密
https://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3
while 1: try: secret_key =list(input()) passward = list(input()) key = [] secret_str = [] # 建立密匙 for i in range(len(secret_key)): if secret_key[i].isalpha() and secret_key[i] not in key: key.append(secret_key[i]) for i in range(26): if chr(ord('a') + i) not in key: key.append(chr(ord('a') + i)) alphabeta = list('abcdefghijklmnopqrstuvwxyz') for i in range(len(passward)): secret_str.append(key[alphabeta.index(passward[i])]) print(''.join(secret_str)) except: break