如何将数字列表转换为字母列表,Python

python 新手,我正在尝试编码加密消息


字母表改写如下:


cipher = [ "q", "a", "z", "w", "s", "x", "e", "d", "c", "r", "f", "v", "t", "g", "b", "y", "h", "n", "u", "j", "m", "i", "k", "o", "l", "p"]


idx = ord ("d") - ord ("a")


print(cipher[3])

输出:w


input = str(input('Write Text: ')) #hello world used here

input = input.lower()

output = []

for character in input:

    number = ord(character) - 97

    output.append(number)

print(output)

输出:


[7, 4, 11, 11, 14, -65, 22, 14, 17, 11, 3]


不知道这两个怎么对应...


我试过了:


print(cipher[output])

返回类型错误:列表索引必须是整数或切片,而不是列表


开心每一天1111
浏览 122回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python