Build a Caesar Cipher - Step 4

Tell us what’s happening:

Why doesn’t it work altho the output is the full alphabet??
alphabet = ‘abcdefghijklmnopqrstuvwxyz’
shift = 5
shifted_alphabet = alphabet[:shift] + alphabet[shift:]
print(shifted_alphabet)
output → abcdefghijklmnopqrstuvwxyz

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.

Your code so far


# User Editable Region

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

# User Editable Region

Your browser information:

User Agent

Challenge Information:

Build a Caesar Cipher - Step 4

shifted_alphabet = alphabet[shift:]

This is the original code you were supposed to concatenate the missing first portion of the alphabet to. You changed that.

shifted_alphabet = alphabet[:shift] + alphabet[shift:] There small mistake in this code.

removed by moderator

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.

Also, please don’t post to old topics. This topic is over 2 months old.