题解 | #字符串加密#
字符串加密
https://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3
# 如果单词中包含有重复的字母,只保留第1个,将所得结果作为新字母表开头 key=input() s=input() # a-z字母表 alpha=[] for i in range(97,123): alpha.append(chr(i)) # key去重 alpha1=[] for i in key: if i not in alpha1: alpha1.append(i) # 新字母表补足 for i in alpha: if i not in alpha1: alpha1.append(i) for i in s: for j in alpha: if i==j: print(alpha1[alpha.index(i)],end='') #print(alpha) #print(alpha1)