Write a secret code program that encrypts messages entered with your own mathematical formula. For this assignment, you will add a “decoder” function to your program using lists. First, update the encoding function so that, as each character is encoded, it is placed in a list. Then, write a new decoding function that, when called, iterates over the list and prints out the original string. This is what I have so far but I'm not sure what I'm doing wrong can get some help please:

- Code: Select all
`#Encoded Secret Code of the users input message and then decodes it.`

encoded = '' "

def encoded_message(message_user):

'''Encodes a message for the user using a mathematical formula based off unicode'''

for a in message_user:

actual_unitary_code = ord(a)

math_formula_change = ((actual_unitary_code * 3) - 13)*2

math_formula_change = str(math_formula_change)

global encoded

encoded = encoded + math_formula_change + ' '

return encoded

def decoded_message(encoded_unicode):

'''Decodes the message the user gave'''

for a in encoded_unicode:

encoded_unicode.append(a)

a=((a/2)+13)/3

encoded_unicode = chr(a)

print(encoded_unicode)

def main():

'''Asks user what he/she wants to encode and then returns the encoded message after using the unitary code'''

encoded_list = []

user_message = input("Please enter a message that you want to encode: \n ")

encoded = encoded_message(user_message)

encoded_list.append(encoded)

print(encoded_list)

decoded_message(encoded_list)

main()