Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions

Question

After you have finished reading this chapter, you will be able to

Answered: 1 week ago