To complete the 4th task in the coded corrspondence assignment I’ve written the following code to decipher a message:
alphabet = "abcdefghijklmnopqrstuvwxyz" punctuation = "!.,? " def decoder(message, offset): translated_message = "" for character in message: if not character in punctuation: index_character = alphabet.find(letter) translated_message += alphabet[(index_character + offset) % 26] else: translated_message += character return translated_message coded_message = "jxu evviuj veh jxu iusedt cuiiqwu yi vekhjuud." print(decoder(coded_message, 10))
However, when I run this code it seems to convert every character in the coded message to the letter “j”. I cannot quite figure out what I’m doing wrong here. Any suggestions would be much appreciated!
Best wishes, Alexander.