(encode/decode sections) Hello, I am having troubles actually taking the letter i found in the key or the alpha and making it the new plain for the main functions. Every time when I try to run the program it just says must be str not int. Which does make any sense because the string is a str. Any thoughts?
""" crypto.py Implements a simple substitution cypher """ alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" key = "XPMGTDHLYONZBWEARKJUFSCIQV" def menu(): print(' Secret Decoder Menu') print() print(' 0)' 'Quit') print(' 1)' 'Encode') print(' 2)' 'Decode') print() response = input('What would you like to do? ') return response # when the user tpyes a number it sends the answer beck to the main function where it can be used in the while loop def encode(plain): new_word = " " for letter in plain.upper(): if letter in alpha: letter.find(key) keyLetter = letter.find(key) plain = new_word + keyLetter return plain def decode(coded): new_word = " " for letter in coded.upper(): if letter in key: letter.find(alpha) keyLetter = letter.find(alpha) coded = new_word + keyLetter return plain def main(): keepGoing = True while keepGoing: response = menu() if response == "1": plain = input("text to be encoded: ") print(encode(plain)) print() elif response == "2": coded = input("code to be decyphered: ") print (decode(coded)) print() elif response == "0": print ("Thanks for doing secret spy stuff with me.") keepGoing = False else: print ("I don't know what you want to do...") main()