I've done this far for spy life challenge but... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I've done this far for spy life challenge but...

import re message=str(input()) string=message[::-1] only_alpha = "" for char in string: if char.isalpha(): only_alpha += char no_specials_string = re.sub('[!#?,.:";+-^*&(){}[]~/\¿¡°`•|×÷=%@]', '', only_alpha) print(no_specials_string) But how would I add the spaces there? This code keeps removing spaces.

7th May 2020, 6:42 PM
B.D
B.D - avatar
1 Answer
+ 4
You don't need to use regex at all. Just add elif char.isspace(): only_alpha += char To your loop and then print only_alpha
7th May 2020, 6:54 PM
ChaoticDawg
ChaoticDawg - avatar