Question: Create a python function, encrypt()that prompts the user for an a file name (e.g., message.txt) and read the textual content of the file and substitute

Create a python function, encrypt()that prompts the user for an a file name (e.g., message.txt) and read the textual content of the file and substitute the alphabetic characters in the message with the next character in the English alphabet, i.e., a becomes b, m becomes n. If there are z letters, substitute those with a. Leave non-alphabetic characters as is in the encrypted message. Then the function should print the encrypted message. Disregard the case of characters. Use exception handling to handle the errors resulting in if the user inputs a wrong file name. Use the sample.txt provided to test your program.
Example output:
>>> encrypt()
Enter file name: sample.txt
uijt jt b tbnqmf ufyu gjmf. uijt gjmf dpoubjot b tbnqmf ufyu cvu op tbnqmf ps ufyu. ufyu jt jo uijt gjmf.
>>>
file contents sample.txt
This is a sample text file. This file contains a sample text but no sample or text. Text is in this file.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!