I have a list in python
a=['one_foo','two_foo','bar_foo']
Expected output:
['one','two','bar']
I tried doing by first converting list into string and then using regex
import re
re.sub("_.*$","", str(a))
I know converting list to string is incorrect way to achieve this task,may be is there any elegant way without converting it to string?