I'm trying to make the Caesar cipher and I'm having a problem with it.
It works perfectly but I want to have spaces added to the word that is inputted. If you enter a sentence with spaces in it. It just prints out = instead of a space when it is Encrypted. Can anyone help me fix this so that it will print out spaces?
Here is my code:
word = input("What is the message you want to encrypt or decrypt :")
def circularShift(text, shift):
text = text.upper()
cipher = "Cipher = "
for letter in text:
shifted = ord(letter) + shift
if shifted < 65:
shifted += 26
if shifted > 90:
shifted -= 26
cipher += chr(shifted)
if text == (" "):
print(" ")
return cipher
print (word)
print ("The encoded and decoded message is:")
print ("")
print ("Encoded message = ")
print (circularShift(word , 3))
print ("Decoded message = ")
print (circularShift(word , -3))
print ("")
input('Press ENTER to exit')