Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started