i have a list like
['hold', 'summit', 'septemb', '8', '9', '.', "'s", 'nancy-amelia', 'sydney', '.', 'energy', ',']
I want to remove all integers, 'dot' , quotes in "s", 'Comma', 'double quote' from such list in one go Or I want to only keep the string entries only i.e hold, summit etc. in the list and remove all other things
Thank in advance
>>> lst=['hold', 'summit', 'septemb', '8', '9', '.', "'s", 'nancy-amelia', 'sydney', '.', 'energy', ',']
>>> import re
>>> list(filter(lambda x:x, map(lambda x:re.sub(r'[^A-Za-z]', '', x), lst)))
['hold', 'summit', 'septemb', 's', 'nancyamelia', 'sydney', 'energy']
>>>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With