Build a Caesar Cipher - Step 4

Tell us what’s happening:

I have no idea why my code is not being accepted. Enlighten me please🙏.

Your code so far


# User Editable Region

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

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0) Gecko/20100101 Firefox/142.0

Challenge Information:

Build a Caesar Cipher - Step 4
https://www.freecodecamp.org/learn/full-stack-developer/workshop-caesar-cipher/step-4

do you think your new alphabet should contain spaces?

I guess not but even without spaces, it doesn’t work

cab you share your updated code?

oh, wait, you have not updated shifted_alphabet, instead you created a new variable

I have opened an issue to make the instructions more clear

I still can’t progress, is this what I was supposed to do;

alphabet = ‘abcdefghijklmnopqrstuvwxyz’

shift = 5

shifted_alphabet = alphabet[shift:]

print(shifted_alphabet)

shifted_alphabet = alphabet[:shift] + alphabet[shift:]

print(shifted_alphabet)

you should not duplicate lines, update that first line in which you are creating shifted_alphabet

Like so?

alphabet = ‘abcdefghijklmnopqrstuvwxyz’

shift = 5

shifted_alphabet = alphabet[:shift] + alphabet[shift:]

print(shifted_alphabet

that would be the intended way to pass the step yes

Since this code wasn’t accepted either, should I just give up for now?

no, you should reset the step and try again, and share your updated code if it does now work

When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

you’ll need to add them at the end of the shifted alphabet.

The correct output in the console should be:
fghijklmnopqrstuvwxyzabcde

This way the alphabet has “shifted” 5 characters. The 6th character is now the 1st character.

1 Like

It finally worked…I did exactly as @pkdvalis said. I appreciate the help so much and look forward to troubling you with more queries.

code removed by moderator

hi @loreta

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

1 Like

remove first two lines