How should I extract numbers only from
a = ['1 2 3', '4 5 6', 'invalid']
I have tried:
mynewlist = [s for s in a if s.isdigit()]
print mynewlist
and
for strn in a:
values = map(float, strn.split())
print values
Both failed because there is a space between the numbers.
Note: I am trying to achieve output as:
[1, 2, 3, 4, 5, 6]