I have a list of words resembling the following
mylist=["hi", "h_ello", "how're", "you", "@list"]
I would like to pull out all of the non-alpha numeric characters to give a results such as:
"h_ello", "how're", "@list"
Please note I have a much longer list in real life, and it contains some non-alpha numeric instances such as ~, ?, >, =, + etc.
Does anyone know how to do this ,please? Thank you
Use str.isalpha()
Ex:
mylist=["hi", "h_ello", "how're", "you", "@list"]
print([i for i in mylist if not i.isalpha()])
Output:
['h_ello', "how're", '@list']
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