所以我们有两个列表,a,它只由字母字符组成,b,它是用户对列表的输入。我正在尝试更改b关于它们在 中的索引a的字母字符,而不更改用户输入中的非字母字符。
alphabet=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
a=input("Please enter a string: ")
b=list(a)
f=[]
for elem in b:
if elem in alphabet:
c=alphabet.index(elem)
d=(len(alphabet)-c)
e=alphabet[d-1]
f.append(e)
mystring=''.join(f)
print(mystring)
我希望 abc123 的输出是 zyx123
有只小跳蛙
一只斗牛犬
相关分类