Instruction : At the end of your loop body, declare a variable called new_index and assign the value of index + shift to this variable.
Keeps showing error’ You should assign ‘index + shift’ to your new variable at the end of your ‘for’ loop body.’
Your code so far
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
for char in text.lower():
index = alphabet[0]
print(char, index)
new_index = 'index + shift'
# User Editable Region
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
for char in text.lower():
index = alphabet[0]
print(char, index)
new_index = 'index + 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/122.0.0.0 Safari/537.36
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 30
Hi Daniel, thank you for the warm welcome and guidance. However, it still shows error message despite removing the quotation marks.
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
for char in text.lower():
index = alphabet[0]
print(char, index)
new_index = index + shift
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.