The Spy Life
Note: This page contains a small but interesting piece of Python code which I call snippets. You can find more such codes on my Python snippets page.
Contents
Problem ¶
You are a secret agent, and you receive an encrypted message that needs to be decoded. The code that is being used flips the message backwards and inserts non-alphabetic characters in the message to make it hard to decipher.
Task:
Create a program that will take the encoded message, flip it around, remove any characters that are not a letter or a space, and output the hidden message.
Input Format:
A string of characters that represent the encoded message.
Output Format:
A string of character that represent the intended secret message.
Sample Input:
d89%l++5r19o7W *o=l645le9H
Sample Output:
Hello World
Solution ¶
Here is my solution to the above problem. Remember that there could be more than one way to solve a problem. If you have a more efficient or concise solution, please leave a comment.
import re
print("".join(re.findall('[a-zA-Z\s]',input()[::-1])))
The problem question is picked from SoloLearn. Here is my SoloLearn code and my SoloLearn profile page.
Last updated 2021-01-09 22:14:45.989461 IST
Comments