Hey there I’m on the Coded Correspondence project and I’m struggling to figure out the math of it.

So as I understand every letter is to be shifted to the left 10 spaces. When I do this I don’t get a word. For example the first coded word is ‘xuo’ shifting x 10 spaces to the left is n shifting u 10 to the left would be k shifting o 10 to the left would be e that gives us ‘nke’ which isn’t a word I understand it says to use the ‘modulus operator’ but I can’t figure out why. I’m completely stumped. Thanks for your help.

Hey, dont forget that you are decoding first so at beginning u dont do i-10 for finding the index corresponding to a letter of an alphabet but i+10, and (i+10) need to be % 26!

Hope it will help

1 Like

Oh ok! Thanks for your help!

Yes, `%`

is used so that the index you get is inside the array (list) you have for the alphabet.

As long as `x`

is a positive integer,

`x % 26`

would be an integer form `0`

to `25`

.

… that way you can avoid trying to use an index that would cause an error.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.