# Project 2: ROT13 Cipher # define the alphabet as one long string alphabet = "abcdefghijklmnopqrstuvwxyz" # get user input, store it as a string secret_code = input("Please enter the secret text.\n") # convert to lower case secret_code.lower() print(f"Original text: {secret_code}") #initialize empty output string output = "" #for each character in user input for char in secret_code: # get the position of each letter in the alphabet index = alphabet.find(char) # if position not found if index == -1: # don't translate, write directly to output output += char # otherwise else: # shift the character by 13, according to alphabet string index += 13 # deal appropriately with remainder. If using modulo, this # will do nothing if index is already less than 26 index = index % 26 # write the output output += alphabet[index] # print new string (the encrypted message) # It should work in reverse! print(output)