Learn String Manipulation by Building a Cipher - Step 16

Tell us what’s happening:

I am a little befuddled by this task. I should assign the shifted variable the Letter from the alphabet that is on the place (index+shift).
At first i got stuck by just recieving the number instead of the letter but now i recieve a clear k when i print shifted, but i am still stuck.

Your code so far

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
index = alphabet.find(text[0].lower())
shifted = (alphabet[index+shift])
print (shifted)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 16

Hello Haniro,

You don’t need the () brackets around alphabet[index+shift].

1 Like

Thank you i tried it out right the second you sent the reply.
Is there i reason why it still works in the console but not for the task? Would there be some bad ramifications later down the line if i wouldn’t spot that error in a live environment?

It doesn’t really matter in real code. But it’s unnecessary, and therefor a little messy.

Think about it this way. In math if you do 3 * 2 + 4, you know you get 10 because of the order of operations. So you wouldn’t have to do (3 * 2) + 4. But even if you did do so, it’s still the same outcome.