I cannot figure out what this is asking and every other question/answer on the forum is not helpful.
Looking for a better explanation and guidance here please
Code so far:
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
index = alphabet.find(text[7].lower())
print(index)
shifted = index + shift
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 16
What specifically about the instructions is confusing? Please donât just copy-paste the instructions but instead talk about what has you stuck
After looking at all the other forums it seems we are confused that looks like itâs asking us to calculate the two numbers. Which would be 10.
I donât follow.
Declare a variable named shifted
and assign it the alphabet
letter at index
plus shift
.
This isnât talking about 10 anywhere? I donât see you using the alphabet in your code but the instructions mention it, so thatâs probably a problem.
The alphabet letter at index, to me, is implying the index variable.
What does âassign it the alphabet letter at indexâ mean then?
You need to use the alphabet variable. Otherwise, why would the instructions mention that variable an all.
What type of data is stored in the alphabet variable?
its a string.
I have now tried this because Iâm kind of following what you are saying but still lost as this code doesnât work either.
shifted = (alphabet.find(text[7].lower()) + shift)
You shouldnât be making a function call here.
You have a string. To get a single character out of a string, you need to âindex intoâ the string, like you indexed into the string âtextâ
shifted = alphabet.find(text[7].lower()) + alphabet.find(shift)
Iâm trying here! lol
I donât understand what it is asking
Donât use find.
Again⌠How did you index into the âtextâ variable? What did you use specifically right next to the text variable to get the 8th character?
I used [7] to get to the 8th character. But Iâm using the find function to look for it.
ILM
December 27, 2023, 6:02pm
12
you used [7]
to get the 8th character of one string, and used the find
function to find it in a different string
you want to use bracket notation when you have the index
Donât think about find. Donât use find. This step is not about find.
Using text[7] indexes into the text variable.
You need to do something similar for the alphabet variable.
1 Like
shifted = alphabet[7] + shift
This isnât working either.
ILM
December 27, 2023, 6:11pm
15
you need to use the two variables to calculate the new index
1 Like
what does this mean? There are 4 different variables.
I was told not to use find, but in order to âfindâ the value of shift then we need to find that value in alphabet, then add them together.
ILM
December 27, 2023, 6:14pm
17
The instructions name two specific variables to calculate the new index
Declare a variable named shifted
and assign it the alphabet
letter at index
plus shift
.
shifted is the only variable that itâs stating to name.
There are 4 variables there. You can tell because they are in a different font
1 Like
well now I tried to dial down to just the alphabet and Iâm not getting anywhere.
index = alphabet[7]
shifted = index + shift