Nov-11-2022, 09:03 PM
(This post was last modified: Nov-11-2022, 09:03 PM by deanhystad.)
(Nov-11-2022, 07:42 PM)MrKnd94 Wrote: [Yes, I do know that neitherBy defining them?Quote:messageor maybeQuote:shifthasn't been defined. How can I fix it please?
The errors are in
encrypt(message, shift)and
decrypt(message,shift)For encrypting the message, how is your program supposed to accept input? Does the user type in a message? Are there test messages you are supposed to encrypt? Any of these would work:
encrypt(input("Enter message: ", 8) encrypt("This is the message", 5) message = "This is the message" shift = 9 encrypt(message, shift)The same goes for decrypt.
Instead of printing, your functions should return the modified string. That way you could print the encoded message to the console, or email the message, or have it printed in invisible ink. You could also pass the encrypted message as an argument to the decrypt() function to decrypt the encrypted message.
shift = int(input("Enter shift: ") message = input("Enter Message: ") message = encrypt(message, shift) print(f'The encrypted message is "{message}"') message = decrypt(message, shift) print(f'The decrypted message is "{message}"')