Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
In a long English secret, the most common letter is x. What shift does the rule guess? What if it is b?
shift = (place of the commonest letter minus place of e) % 26
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, compare your working with the solution.
The rule: the commonest letter stands for e, so the shift is the distance from e to it, wrapped with % 26.
x is place (counting a as ) and e is place . The shift is .b is place . Then , and . The shift is .Python's % gives a positive answer, so (1 - 4) % 26 is .
Log in to join the discussion.
Loading…