I'm working on a Caesar Cipher for my class, and it prints everything just fine. However, if I put uppercase letters in the plaintext, the ciphered text comes out lowercase.
#Main program
def main():
alphabet = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'
key = int(input("enter key: "))
inputText = input("enter message: ")
outputText = ''
direction = input("Encrypt or decrypt (e/d)?: ")
for x in inputText:
if x == ' ':
outputText = outputText + ' '
else:
for i in range(0,len(alphabet),1):
if x.lower() == alphabet[i]:
if (direction == 'e'):
outputText = outputText + alphabet[i + key]
break
else:
outputText = outputText + alphabet[i - key]
break
print(outputText)
#Run and repeat loop
while True:
main()
if input("Repeat the program? (Y/N): ").strip().upper() != 'Y':
break
Do I need to add an extra alphabet just for uppercase letters or is there a way for it to recognize them?