Learn String Manipulation by Building a Cipher - Step 26

Tell us what’s happening:

what might be the output of this? : Inside the for loop, before printing the current character, declare a variable called index and assign the value returned by alphabet.find(char) to this variable.

Your code so far

text = 'Hello World'
shift = 3

# User Editable Region

alphabet = 'abcdefghijklmnopqrstuvwxyz'
index=alphabet.find(i)
for char in alphabet:
    print(char)
    index=alphabet.find(char)

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

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 26

Hi there! Please look at the instructions carefully:

before printing the current character, declare a variable called index

1 Like

hey actually thanks for your reply, english is not my first language.wait let me give you my code.i am newbie XD: text = ‘Hello World’
shift = 3
alphabet = ‘abcdefghijklmnopqrstuvwxyz’
index=alphabet.find(i)
for char in alphabet:
print(char)
index=alphabet.find(char)

This is your initial code. You still need to change the order of your last lines co complete this step, print(char) should be at the end

1 Like

text = ‘Hello World’
shift = 3
alphabet = ‘abcdefghijklmnopqrstuvwxyz’
for char in text:
print(char)

And where’s declaring of index?

– removed solution –

ps:yo bro finally solved …thanks

1 Like

You’re welcome!
Also, 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

And in the future please don’t share your solutions here on the forum. Thank you.

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