Learn String Manipulation by Building a Cipher - Step 16

Tell us what’s happening:

what code should I write to pass step 16 Learn String Manipulation by Building a Cipher -

Your code so far


# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
index = alphabet.find(text[0].lower())
shifted='d+shift
'

# 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/120.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 16

Welcome to the forum @Nami

image

You declared the shifted variable correctly, however it is not referencing the alphabet string at the required index.

Happy coding

1 Like

Welcome to our community!

Don’t change the given code in this challenge. You have deleted the print function.
Restart the step.
The instructions: " Declare a variable named shifted and assign it the alphabet letter at index plus shift"

The variable’s value should be a letter from the alphabet variable at the index index + shift:

variable =  alphabetvariable[required index shown above]

This is guidance.

Don’t use single quotes around the assigned value.

1 Like

thank u so much for your help but I can’t figure out the value of the variable I declared .
i tried this but it didn’t work out:
text = ‘Hello World’
shift = 3
alphabet = ‘abcdefghijklmnopqrstuvwxyz’
index = alphabet.find(text[0].lower())
print(text.lower())
shifted= h+3

Use the variables mentioned in the instructions, instead of using numbers.

Give us an explanation of what you want to achieve with the h+3?

they needed to find the letter at index 7 in the “alphabet” variable wich is ‘h’ plus the value of variable “shift” wich is '3 ’ THAT’s why I writed: shifted= h+3

You have to find the letter from the alphabet variable, at the index: index + shift. The index and the shift are already declared variables. Instead of using a concrete letter and the value of the ‘shift’ variable, you should use as index: [index + shift]:

your_new_variable = variable[index] ... guidance
  • the ‘variable’ is the alphabet,
  • the ‘index’ is given in the text above.
1 Like

Thank u so much for your time. I really appreciate your help :blush:

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.