Question: Can you help me with the third question? Write a function cipher(plaintext, n) to shift all characters in a string of text. Your function should

Can you help me with the third question?

Write a function cipher(plaintext, n) to shift all characters in a string of text. Your function should take 2 parameters, the plaintext to shift (a string) and the shift key n (an integer). Set up an accumulator variable (suggested name: ciphertext) in which to accumulate the result. Use a definite loop with the accumulator pattern to go through all characters in plaintext. For each character, call your shift_char function to obtain the shifted version of that character, which you will concatenate into ciphertext. Return the ciphertext after the loop. Here are some test cases: >>> cipher('time', 4) 'xmqi' >>> cipher('welcome to the machine', 19) 'pxevhfx mh max ftvabgx'

3>>Suppose you have some ciphertext (i.e., 'iuet kag iqdq tqdq', or 'prqhb') but you dont know which decryption key (i.e., the number of characters to shift) to use. Write a function called codebreaker(ciphertext) that will try all possible Caesar cipher shifts (there are only 26 to try) and print out each possible deciphering. One of them will stand out as a valid English phrase. Your program must re-use your cipher function from question 2 above.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!