+ 2

The Spy Life from code couch. Help

import re text = str(input()) result = re.sub(r"[^\w]", "", text, flags=re.I) res = re.sub(r"\d", "", result, flags=re.I) def reverse(res): res = res[::-1] return res print (reverse(res)) #how can i not delete the spaces, without mentioning each symbol to remove?

3rd Jan 2020, 2:07 PM
Νικος Παγκαλης
Νικος Παγκαλης - avatar
13 Antworten
3rd Jan 2020, 10:39 PM
Νικος Παγκαλης
Νικος Παγκαλης - avatar
+ 4
Instead of trying to delete you can find just the strings and spaces instead. For example import re inp = input() print(''.join(re.findall(r'[a-zA-Z]|\s', inp[::-1])))
23rd Jan 2020, 12:22 AM
Onuoha_ifeanyi
Onuoha_ifeanyi - avatar
21st Jun 2020, 3:51 PM
McInventor29
McInventor29 - avatar
+ 2
My solution of "The Spy Life": code_text = input() uncode_text = "" number = -1 while number >= -(len(code_text)): if code_text[number].isalpha() == True or code_text[number].isspace(): uncode_text += code_text[number] number -= 1 print(uncode_text) What are You thinking about?
23rd Jun 2021, 9:05 AM
Przemysław Komański
Przemysław Komański - avatar
23rd Jul 2020, 5:15 PM
Israel Flores
Israel Flores - avatar
+ 1
Not fancy but it works : x=input() y=x[::-1] z='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ' for i in y: if i in z: print(i, end='') else: print('', end='')
24th Jan 2022, 5:41 AM
Gelndjj
Gelndjj - avatar
0
num=input() alph="abcdefghijklmnopqrstuvwxyz" p="" q="" for i in num: if i==" ": p+=" " if i in alph: p+=i for k in range(len(p)): q+=p[-k-1] print(q)
8th Oct 2021, 9:09 PM
Ayodeji Akinkuowo
Ayodeji Akinkuowo - avatar
0
This works too: import re txt = input() pattern = r'[a-zA-Z\s]' ans = re.findall(pattern, txt) anss = ans.reverse() print("".join(ans))
24th Apr 2022, 1:57 AM
Jed
0
import re x=input() x=re.sub('[^a-zA-Z\s]', '',x)[::-1] print(x)
26th Jul 2022, 9:23 AM
Muce Madra
Muce Madra - avatar
0
Nowadays, it is very easy to follow someone else's life using social networks or a smartphone. I am very worried about this and I am afraid of hackers who are everywhere, so I use the recommendations https://theteensafe.com/iphone-keylogger/ , there is everything about the protection of all social networks and the smartphone. I found it useful and I want to share it with you.
24th Apr 2023, 2:13 PM
Karol Legerd
Karol Legerd - avatar
0
import re encrypt=input() pattern=re.compile("^[a-zA-Z\s]") w=[] c=0 for i in encrypt: match=re.search(pattern,i) if match: w.append(i) c+=1 w.reverse() print("".join(w))
25th May 2023, 11:50 PM
Nkeh Bebey
Nkeh Bebey - avatar
0
This code I wrote to validate my answer
25th May 2023, 11:51 PM
Nkeh Bebey
Nkeh Bebey - avatar