They ask me to do this : Give your for loop a body by adding a call to print(i) . Remember to indent the loop body.
I have no idea of what is wrong with my code… can somebody help ?
Your code so far
/* User Editable Region */
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
text = lower(text)
for i in text:
shifted = alphabet[i+shift].find(text(i))
print(i)
/* 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/120.0.0.0 Safari/537.36
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 19
Oh it worked ! But I still don’t understand why it didn’t worked… The text is in lower case and upper case instead of only lower case so why is the output not the same ?
It didn’t work because you changed the values of the text variable.
I’ll give an example: When you create a variable, you can change its value.
So if you created a variable like,
text = ‘apple’
and then somewhere later down you also write
text = ‘oranges’
you’ve just changed what’s contained within the text variable
so if you print text it will print oranges instead of apples because you changed its value.
The original value of text is ‘Hello World’
text = ‘Hello World’
But when you wrote,
text = lower(text)
you changed the original value was from ‘Hello World’ to lower(text)
thus, it won’t print ‘Hello World’
But the challenge wants you to print "Hello World’ by way of a for loop