Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Cipher
6. Cracking the cipher

Instruction

Good job! Here comes the next exercise.

The only difference between a cipher and a decipher function would be the subtraction of the shift value instead of addition. However, you must know the value the letters were shifted by, otherwise, it wouldn't be a cipher at all.

You don't have to create a separate decipher function. The cipher() function perfectly fits our needs. As you already know, it just shifts the letters by a particular value between 0 and 25. If you shift the ciphered word the correct number of times, you will "return" to the beginning value, e.g.:

word = "Python"
ciphered_word = cipher(word, 12) # we shift the letters by 12
deciphered_word = cipher(ciphered_word, -12) # we shift the letters by -12 places thus returning to the beginning.

Of course we don't know that 12 is the correct number. We have to iterate through every possibility (in a range from -25 to 0 inclusive) and create a set of all result words.

Exercise

In the Code Editor we've already prepared the ciphered word. Create a function called crack_cipher() that takes a word and returns the set of all possible shifted words.