Write a Python program that reads in a string S and an integer number N and encr
ID: 3763947 • Letter: W
Question
Write a Python program that reads in a string S and an integer number N and encripts S based on N
The process of encryption is
Step 1: reverse the first N characters of S
Step 2: reverse the last N characters of S Note that it is important that the two steps are performed in that order. We will assume that N is smaller than the length of the string S.
Examples of encryption:
The string "This is a test" with the key N=4 is encrypted to "sihT is a tset" The string "
Another example" with the key N=2 is ecnrypted to "nAother exampel"
Explanation / Answer
statement=raw input("Enter statement")
n=int(raw input "Enter N: "
first statement=
last statement=
middle statement=
reversed first=[1::-1]
reversed last=[1::-1]
print "Encrypted: ", reversedfirst +middlestatement+reversedlast
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.