+ 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.
2 Antworten
+ 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