Question: Programming Exercise 4.7 Write A Script That Decrypts A Message Coded By The Method ... Question: Python Programming Exercise 4.7 Write a script that decrypts

Programming Exercise 4.7 Write A Script That Decrypts A Message Coded By The Method ... Question: Python Programming Exercise 4.7 Write a script that decrypts a message coded by the method used i... python Programming Exercise 4.7 Write a script that decrypts a message coded by the method used in Project 6. Method used in project 6: Add 1 to each characters numeric ASCII value. Convert it to a bit string. Shift the bits of this string one place to the left. A single-space character in the encrypted string separates the resulting bit strings. An example of the program input and output is shown below: Enter the coded text: 0010011 1001101 1011011 1011011 1100001 000011 1110001 1100001 1100111 1011011 1001011 000101 Hello world!

 Programming Exercise 4.7 Write A Script That Decrypts A Message Coded

def bits2string(b=''): return chr(int(b, 2) - 1) def shift(n=''): temp = list(n) new = (temp[-1:] + temp[0:-1]) ret = "" for i in new: ret = ret + i return ret coded = input("Enter the coded text: ") process = coded.split(" ") decoded = "" for q in process: decoded = decoded + bits2string(shift(q)) print " Decoded Information: " + decoded

im getting the error "SyntaxError: 'return' outside function"

Programming Exercise 4.7 Instructions Write a script that decrypts a message coded by the method used in Project 6 Llil Method used in project 6: s/p 1. Add 1 to each character's numeric ASCII value 2. Convert it to a bit string 3. Shift the bits of this string one place to the left. A single-space character in the encrypted string separates the resulting bit strings. An example of the program input and output is shown below: Enter the coded text: 0010011 1001101 1011011 1011011 1100001 000011 1110001 1100001 1100111 1011011 1001011 Hello world! Grading When you have completed your program, click the Submit button to record your score

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!