Im trying to make a Vigenère Cipher but I can\'t seem to find a way to implement a feature that ignores in-putted white spaces when entering the message and then printing the fi
You just need to add an else statement in translateMessage()
to add the space to the output like this
def translateMessage(key, message, mode):
translated = ""
keyIndex = 0
key = key.upper()
for symbol in message:
xyz = alphabet.find(symbol.upper())
if xyz != -1:
if mode == 'encrypt' or 'e':
xyz += alphabet.find(key[keyIndex]) + 1
elif mode == 'decrypt' or 'd':
xyz -= alphabet.find(key[keyIndex]) + 1
xyz %= len(alphabet)
if symbol.isupper():
translated += alphabet[xyz]
elif symbol.islower():
translated += alphabet[xyz].lower()
keyIndex += 1
if keyIndex == len(key):
keyIndex = 0
else : translated += symbol #this will add space as it is
return translated