Professional Documents
Culture Documents
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd',
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z']
def caesar(text,shift,direction):
final_text=""
for letter in text:
if letter in alphabet:
position=alphabet.index(letter)
if direction=="encode":
final_position=position+shift
elif direction=="decode":
final_position=position-shift
final_text+=alphabet[final_position]
else:
final_text+=letter
print(f"The {direction} text is {final_text}")
conti=True
while conti:
direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n")
text= input("Type your message:\n").lower()
shift= int(input("Type the shift number:\n"))
caesar(text,shift,direction)
reset=input("Type 'yes' if you want to go again. Otherwise type 'no'.\n").lower()
if reset=="no":
print("good bye")
break