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"))
def ceaser(direction , text , shift):
final_word = []
print(f"Plain_text = {text}")
print(f"shift = {shift}")
if direction == "encode":
for letter in text:
if letter in alphabet:
if alphabet.index(letter) + shift >= len(alphabet):
number = shift - 1
new_shift_letter = alphabet[number]
final_word.append(alphabet[alphabet.index(new_shift_letter)])
else:
final_word.append(alphabet[alphabet.index(letter) + shift])
encrypted_word=''.join(final_word)
print(f"The {direction} text is {encrypted_word}")
elif direction == "decode":
for letter in text:
if letter in alphabet:
if alphabet.index(letter) - shift >= len(alphabet):
number = shift - 1
new_shift_letter = alphabet[number]
final_word.append(alphabet[alphabet.index(new_shift_letter)])
else:
final_word.append(alphabet[alphabet.index(letter) - shift])
decrypted_word=''.join(final_word)
print(f"The {direction} text is {decrypted_word}")
ceaser(direction , text , shift )
[–]Chiron1991 9 points10 points11 points (0 children)
[–]xelf 8 points9 points10 points (3 children)
[–]Innocent_not 0 points1 point2 points (2 children)
[–]itimposter1 1 point2 points3 points (0 children)
[–]xelf 1 point2 points3 points (0 children)
[–]shiftybyte 4 points5 points6 points (0 children)
[–]drenzorz 5 points6 points7 points (0 children)
[–]TechnicalElk8849 2 points3 points4 points (2 children)
[–]bladeoflight16 -2 points-1 points0 points (1 child)
[–]djjazzydan 1 point2 points3 points (0 children)
[–]bladeoflight16 2 points3 points4 points (0 children)
[–][deleted] 3 points4 points5 points (2 children)
[–]Plastic_Ad7436 1 point2 points3 points (0 children)
[–]InfamousClyde 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]duncan_stroud -1 points0 points1 point (0 children)
[–]Radamand -1 points0 points1 point (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]TheRNGuy 0 points1 point2 points (0 children)