Coded Correspondence Challenge Project

I am working through the Coded Correspondence off-platform project and I am bit confused over this line:

                                                   **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:**

Is it just me or does the “resulting place value” examples go off the rails and aren’t correct after the first two cipher/letters. Just by the example above I don’t understand how the resulting place value for the first r is “15” but also the letter “x” at the same time, since that is not the place value of x in the alphabet.

1 Like

Yes, I thought that was off too.

letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] index = {letters[i] : i for i in range(len(letters))} keyword_phrase = "dogdogdogdogdog" message = "barryis" resulting = [] for i in range(len(message)): print(message[i], "+", keyword_phrase[i], end=" ") print(index[message[i]], "+", index[keyword_phrase[i]], end=" ") n = index[message[i]] + index[keyword_phrase[i]] print("=", n, "% 26 =", n % 26, end=" ") print("=", letters[n % 26]) resulting.append(n % 26) print() print(resulting)
1 Like