Write a program that will implement a “shift right by 5” Caesar Cipher Machine. The letters will be entered one character at a time. The program will terminate when an empty input is encountered.
My code
alphabet = "abcdefghijklmnopqrstuvwxyz"
key = "fghijklmnopqrstuvwxyzabcde"
n=input("Enter a letter: ")
message=""
for letter in n:
if letter.lower() in alphabet:
message += key[alphabet.find(letter.lower())]
else:
message += letter
print(message)
I'm fairly new to python and I am having trouble with my code. I want if the user entered nothing when prompt, it will print everything he entered as encrypted key. Also as stated in the question, it should ask for the user multiple inputs and it will only end once the user did not input anything when asked.
Cheers to everyone!
Example
Enter a letter: a
Enter a letter: b
Enter a letter: c
Enter a letter: (empty, enter)
f g h