创建一个凯撒密码 - 步骤15

告诉我们发生了什么:

求助:创建一个凯撒密码的步骤15中,不知道该怎么操作,直接把字符串改成大写也是不行的,提示内容也完全没看懂,请诸位大佬帮忙看一下

你目前的代码

def caesar(text, shift):
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    shifted_alphabet = alphabet[shift:] + alphabet[:shift]
# User Editable Region
    translation_table = str.maketrans(alphabet, shifted_alphabet)
# User Editable Region
    return text.translate(translation_table)

encrypted_text = caesar('freeCodeCamp', 3)
print(encrypted_text)


你的浏览器信息:

用户代理是:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36 Edg/150.0.0.0

挑战信息:

创建一个凯撒密码 - 步骤15

GitHub 链接:i18n-curriculum/curriculum/challenges/chinese/blocks/workshop-caesar-cipher/6818fcb250f34e62cab32c39.md at main · freeCodeCamp/i18n-curriculum · GitHub

Welcome to the forum @sihan,

Currently, both alphabet and shifted_alphabet contain only lowercase letters, right? So, your objective in this step is to add the uppercase version of those variables to what is passed in to maketrans. And you would do that by applying upper() to both variables and concatenating the uppercase version to the lowercase version.

Happy coding