I have been working on this for the last couple of days but don\'t understand wh
ID: 3718841 • Letter: I
Question
I have been working on this for the last couple of days but don't understand what i am doing wrong. I feel I am not taking into account the shift value to decode the encrypted text.
Ive tested with a series of inputs that are supposed to work but only one seems correct
This is the only correct Value
Value is supposed to abcde
Value is supposed to be Hello World
I feel I setup the Shift value incorrect but I am not sure whats wrong exactly.
Explanation / Answer
text = input("Enter plain text: ") s = input("Shift: ") def caesar(plainText, shift): cipherText = "" for char in plainText: val = ord(char) - shift if val < 32: val = 127 - (31 - val) elif val > 127: val = val - 128 + 32 cipherText += chr(val) return cipherText print(caesar(text, int(s)))Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.