Learning String manip by Building a cypher Step 29

Hi,
Everything looks great in my console… How come it does not pass?
Cheers,
G

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'

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

I believe you have things in the wrong order. The instructions say "at the end of the loop body.

Here is the code before any changes:

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'

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

Your print call has an extra argument (new_index) and the new_index variable assignment should happen after the print call.

Hope this helps!

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

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

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

1 Like

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 Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for 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.

1 Like

Cheers, @shwilly-dev! It ran smoothly.
Regards,
G

1 Like

Thanks for those tips, @pkdvalis . I really appreciate your help. First time I posted here ever
Regards,
G

2 Likes