Learn String Manipulation by Building a Cipher - Step 27

Tell us what’s happening:

Describe your issue in detail here.

Your code so far


/* User Editable Region */

text = 'Hello World'
n = text[0]
n = G

/* User Editable Region */

shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'

for char in text.lower():
    index = alphabet.find(char)
    print(char, index)
    new_index = index + shift

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 27

access the first letter in text and try to change it into a character of your choice.

You have assigned the first letter of text to a new variable, n. Then you assigned a new value to n. G isn’t really a string either, you need to put it in quotes.

2 Likes

I wasn’t sure if I should have posted a new thread but my solution is not sufficient for the step 27

text = ‘Hello World’

new_text = ‘Y’ + text[1:]

print(new_text)

Am I misreading the question?

In my output I see that the H in Hello World was successfully changed to a Y making Yello World but when I submit my code I am met with error You should assign a character of your choice to text[0] .

1 Like

Yes, you should always open a new topic, especially since this one is already marked solved.

You are creating a new variable, but you need to try to change the existing variable text. Access the first variable by using index 0. You should assign a character of your choice to text[0] .

I just did:
Mod Edit: SOLUTION REMOVED

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.

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.

My bad, new here. Now I understand.

1 Like

Thank you. That made more sense. I was reading the question wrong and not understanding what step 27 was wanting.

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