Off-Platform Project: Coded Correspondence

https://www.codecademy.com/courses/learn-python-3/informationals/python3-coded-communication

In this project this is what is given:

Now we use the repeat the keyword over and over to generate a _keyword phrase_ that is the same length as the message we want to code. So if we want to code the message "barry is the spy" our _keyword phrase_ is "dogdo gd ogd ogd". Now we are ready to start coding our message. We shift the each letter of our message by the place value of the corresponding letter in the keyword phrase, assuming that "a" has a place value of 0, "b" has a place value of 1, and so forth. Remember, we zero-index because this is Python we're talking about!

                    message:       b  a  r  r  y    i  s   t  h  e   s  p  y

             keyword phrase:       d  o  g  d  o    g  d   o  g  d   o  g  d

      resulting place value:       4  14 15 12 16   24 11  21 25 22  22 17 5

        So we shift "b", which has an index of 1, by the index of "d", which is 3. This gives us an place value of 4, which is "e". Then continue the trend: we shift "a" by the place value of "o", 14, and get "o" again, we shift "r" by the place value of "g", 15, and get "x", shift the next "r" by 12 places and "u", and so forth. Once we complete all the shifts we end up with our coded message:

            eoxum ov hnh gvb

So in this code:

message = β€œdfc aruw fsti gr vjtwhr wznj? vmph otis! cbx swv jipreneo uhllj kpi rahjib eg fjdkwkedhmp!”
keyword = β€œfriends”

d = index 3
f = index 5

so index is at 8 which in the alphabet is β€œi”

but the answer is β€œy”

here is the full sentence answer:
you were able to decode this? nice work! you are becoming quite the expert at crytography!

how did they get y from index 8 in the alphabet?

This is what is written directly in the problem:

So we shift "b", which has an index of 1, by the index of "d", which is 3. This gives us an place value of 4, which is "e".

We are adding the 2 index places together. How in the world do you get β€œy” by adding index places β€œf” and β€œd”

To get β€˜y’, it would appear that the index was shifted to the left instead of to the right.

>>> 3-5
-2
>>> 'abcdefghijklmnopqrstuvwxyz'[-2]
'y'
>>>
1 Like

Is the prompt wrong? Or is my English understanding wrong?

The prompt seems to be asking to add them together, not subtract.

my solution, you can call eather functions at the end to test the coder an decoder

off-platform-project-coded-correspondence.txt (1.1 KB)