Off-Platform Project: Coded Correspondence

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
>>> 'abcdefghijklmnopqrstuvwxyz'[-2]
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)

Very interesting and challenging project.
My solution is here as a jupyter notebook or python code.

Github project

Hi! I have a question about this project. I am trying to understand why index = (index + 1) % len(keyword) works for making the keyword phrase for the Vigenere Cipher instead of just index += 1. Can anyone help me understand? Thanks!

In the ‘dog’ example shown, they are adding the indexes together to encode a message. To decode an encoded message, you need to subtract the indexes.

I found this confusing at first too. And their example with the ‘dog’ encoding doesn’t make much sense. Only the first 2 “resulting place values” shown add correctly, the others in the list seem like garbage to me. If ‘b’ at index 1 plus ‘d’ at index 3 makes 4, then why does ‘r’ at index 17 plus ‘g’ at index 6 make 15, when 17 + 6 is 23. The encoded message uses the letter ‘x’ which is at index 23.

Anyhow, hope this helps!


So if the keyword is ‘friends’, then it’s length is 7 letters long. If you just kept upping the index with ‘index += 1’ then you will surpass the length of the keyword after 7 iterations. Using the mod (%) operator gives you the remainder of the division, which keeps the result in the range of 0-6.

I don’t see this in the solution code, so I am only guessing here. I did it in a different way myself.

This is my solution to this project.

Hi there! I’ve just finished this project.
Came across with the same problem you had mentioned and lost a few hours figuring out that the task (prompt) itself was wrong!
This is the first time Codecademy broke me down(

Wait, so the given “resulting place values” after the first two examples are wrong?! My god I wasted an hour trying to figure out how ‘r’ index and ‘g’ index equals index 15. :rage:
I should have looked at the coded message first.