如果我输入“eat”,我应该得到的输出应该是“hdw”,如果我将它移动 3。但是,最终结果只是“w”。我很确定我有我需要的一切,但也许是格式?
def shifter():
phrase = input("Please enter a message: ")
key = eval(input("Please enter the number of places to be shifted: "))
list = phrase.split()
for word in list:
for ch in word:
conversion = (chr)((ord(ch) - ord("a") + key) % 26 + ord("a"))
newPhrase = " "
newPhrase = newPhrase + conversion
print(newPhrase)
shifter()