#!/usr/bin/python3 # -*- coding: utf-8 -*- from typing import List key: int = int(input("\nEnter your Caesar key in numeric form (1-25): ")) mode: int = int(input("\nEnter 1 for encryption, and 0 for decryption: ")) caesar_encoding: str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" message: str = input("\nEnter your message, in English: ") translated: List[int] = [] for character in message: if mode == 1: # 26 is the symbol set size (# letters in alphabet) encoded_char = caesar_encoding.find(character.upper()) translated.append((encoded_char + key) % 26) else: encoded_char = caesar_encoding.find(character.upper()) translated.append((encoded_char - key) % 26) print("\nYour encrypted text is:") # To print the string: for encoded_char in translated: print(caesar_encoding[encoded_char], end="") print() # Another way to recover the string for later use, if needed: textstring: List[str] = [] for encoded_char in translated: textstring.append(caesar_encoding[encoded_char]) textstring_string: str = "".join(textstring) print(textstring_string) for ichar, character in enumerate(textstring): print("Character:", ichar, "is", character)