Build a Caesar Cipher - Step 4

Tell us what’s happening:

alphabet = ‘abcdefghijklmnopqrstuvwxyz’
shift = 5
shifted_alphabet = alphabet[shift:]
print(shifted_alphabet)
shifted_alphabet = alphabet[shift:] + alphabet[0:shift]
print(shifted_alphabet)

I am very sure this code is correct; it even gives the result on the terminal, but it keeps saying “Sorry, your code does not pass”. What could be wrong?

Your code so far


# User Editable Region

alphabet = 'abcdefghijklmnopqrstuvwxyz'
shift = 5
shifted_alphabet = alphabet[shift:]
print(shifted_alphabet)
shifted_alphabet = alphabet[shift:] + alphabet[0:shift]
print(shifted_alphabet)



# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36

Challenge Information:

Build a Caesar Cipher - Step 4

Use the slicing syntax to extract the missing first portion of alphabetand concatenate it toalphabet[shift:] .

You already have a shifted_alphabet variable. This instruction is asking you to concatenate the missing first portion of the alphabet to the existing shifted_alphabet assignment.

Could you please give me a hint? Am I to create a new variable to concatenate?

You have assigned shifted_alphabet twice. It should only be assigned to once.

1 Like

Am getting the error You should assign the concatenation of alphabet[shift:] and the missing first portion of alphabet to the shifted_alphabet variable on the same line it was declared. Use shift to specify where to stop the slicing.

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.