Question: Imp Your program should begin by prompting the user for a message (a string), a shift amount (aninteger), and whether they would like to encrypt

Imp

Your program should begin by prompting the user for a message (a string), a shift amount (aninteger), and whether they would like to encrypt or decrypt, then our implementation will add some variation to the basic algorithm to make it a little harder to decode. When encrypting:(1) You'll replace each"e" character in the original message with the letters"zw". If the user enters"Hello World!", the resulting message will be"Hzwllo World!".(2) After replacing the "e"characters, you'll add the word "hokie" to the beginning, middle (the middle is length//2), and the end of the message.Continuing with example above the message that's actually encrypted using the Caesar Cipher is "hokieHzwllohokieWorld!hokie" Once you have the altered message then perform the Caesar Cipher encodingas described above,printing the result.When decrypting, perform each step in reverse order. Decrypt the message using the Caesar Cipher, then remove the "hokie" strings, then change any occurrence of "zw" to "e". You mayassume the all occurrences of "zw" in the result are really "e" characters, and further you may assume the "hokie" strings are in the encrypted message at the appropriate place, however there may be other occurrences of "hokie" in the original message. Finally,your program must be able to encrypt/decrypt an arbitrary number of messages. When youve completed the encrypting/decrypting a message the user should be asked if they want to enter another message.Your program should continue until the user types N

where am I messing up?

import string variable = "Y" while variable == "Y": message = input("Enter Message:") k =int(input("enter shift amount:")) EncodeDecode = input('Encode (E) or Decode (D)') something="" if EncodeDecode == "E": message = message.replace("zw","e") length = len(message) message = 'hokie'+message[:length//2]+'hokie'+message[:length//2]+'hokie' for x in message: if x.isupper(): x=(((ord(x)-65)+k) % 26) result=(chr(x+65)) something += result elif x.islower(): x=(((ord(x)-97)+k) % 26) result=(chr(x+97)) something += result else: result=(chr(ord(x))) something += result print("result: ", something) variable = input("Go again? (Y/N):") if EncodeDecode == 'D': for x in message: if x.isupper(): x=(((ord(x)-65)+k) % 26) result=(chr(x+65)) something += result elif x.islower(): x=(((ord(x)-97)+k) % 26) result=(chr(x+97)) something += result else: result=(chr(ord(x))) something += result print("result: ", something) variable = input("Go again? (Y/N):")

message = message.replace("e","zw") length = len(something) message = something.replace('hokie' ,"")

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!