#I have been looking at forums and reset this code few times already I cant get it to submit. Not sure what the issue is. Any help would be appreciated. Thanks
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
for char in text.lower():
index = alphabet.find(char)
new_index = index + shift
print(char, index)
error
*Sorry, your code does not pass. You’re getting there.
You should assign index + shift to your new variable at the end of your for loop body.
I tried to print as
print(char, new_index) no good there either
Thank you that did it. I dont know how that is body of “for” loop when its after print function. But it took it successful. Thank you for quick response
The body of the for loop is anything intended one level after the line for ending with colon. At the end of your for loop body, would be interpreted as after the for loop which means at the same level of indentation that the word for
To elaborate on that, maybe you are thinking of a return statement. A print function can be placed anywhere in the code, it’s a popular debugging method in many languages.
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.