间谍译码
大神们帮帮忙我sololearn的一个 python题目,求帮忙,要求是英文的,要求如下: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 import re
s = "d89%l++5r19o7W *o=l645le9H"
print(re.sub(r"[^a-zA-Z ]", "", s[::-1])) isdkz 发表于 2022-4-11 21:03
有没有更常规的解法呢? 阿育王 发表于 2022-4-11 21:09
有没有更常规的解法呢?
s = "d89%l++5r19o7W *o=l645le9H"
result = ""
for i in s[::-1]:
if "a" <= i <= "z" or "A" <= i <= "Z" or i == " ":
result += i
print(result) isdkz 发表于 2022-4-11 21:03
大神,求加微信好友哇{:10_254:}本人微信号553915465
页:
[1]