Let's say I have a list like so:
a = ['abc1', '2def', 'g3h']
And I am trying to make it like this using list comprehension:
['abc', 'def', 'gh']
What I've tried:
[''.join([x for y in a for x in y if x.isalpha()])]
Which produces:
# ['abcdefgh']
Is there a neat way of achieving ['abc', 'def', 'gh'] using list comprehension?
[re.sub('\d+', '', _) for _ in a]andimport re