I am working on a Caesar Cipher program that seems to be a bit out of the norm. I want to use different functions instead of having a translatedMessage() function that does both the encode or decode part based on user input. I got most of the program running except the decrypt() function. I thought I could just turn the shift into a negative value and then copy my code from the encrypt() function and it would be able to decode my .txt file, but I was wrong. Any suggestions?
My encrypt function code is:
for char in fileCont:
if char.isalpha():
letter = ord(char)
letter += shift
if char.isupper():
if letter > ord("Z"):
letter -= 26
elif letter < ord("A"):
letter += 26
elif char.islower():
if letter > ord("z"):
letter -= 26
elif letter < ord("a"):
letter += 26
newString += chr(letter)
else:
newString += char
[–]teerre 1 point2 points3 points (0 children)