擅长:python、mysql、java
<p>仅更改最后一个字母,因为您正在从原始输入字符串在每个循环上创建<code>ciphered</code>字符串,因此在最后一个循环上,仅更改最后一个元素</p>
<pre><code>string = input("Enter your string ")
ciphered = ""
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
cipher = "ZYXWVUTSRQPONMLKJIHGFEDCBA"
for i in string:
char = alphabet.find(i)
ciphered += cipher[char]
print(ciphered)
</code></pre>
<p>这应该行得通</p>