我创建了一个函数来将输入的字符串拆分为单词列表,然后将每个单词中的字母替换为其移位的对应物,但是当我将移位设置为超过 30 时,它的打印结果不变。
def ceaser_cipher_encoder(string , num):
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"]
new_string = ""
string_list = string.split(" ")
new_list = []
for word in string_list:
word1 = ""
for charecter in word:
letter_position = alphabet.index(charecter)
letter_position_with_shift = letter_position + num
if letter_position_with_shift > 25:
letter_position_with_shift = 0 + ((letter_position - 25) - 1)
word1 += charecter.replace(charecter, …Run Code Online (Sandbox Code Playgroud)