Question: Write a script in the file encrypt.py that inputs a line of plaintext and a distance value and outputs an encrypted text using a Caesar

Write a script in the file encrypt.py that inputs a line of plaintext and a distance value and outputs an encrypted text using a Caesar cipher. The script should work for any printable characters. (LO: 4.1,4.2)
Status: FAILED!
Check: 2
Test: Program outputs correct values when user inputs message and distance of 127
Reason: Unable to find '['`abcde']' in the program's output.
My code outpu:
Here is my code:
text = input("Enter a line of text to encrypt in lowercase: ")
distance = int(input("Enter the distance value: "))
code =""
for ch in text:
ordvalue = ord(ch)
cipherValue = ordvalue + distance
if cipherValue > ord('z'):
cipherValue = ord('a')+ distance -(ord('z')- ordvalue +1)
code += chr(cipherValue)
print(code)
What can I add to my code for it to cover punctuation?

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!