I want to extract all the elements of a list from the first non-numeric element:
input = [u'12', u'23', u'hello', u'15', u'guys']
I want:
output = [u'hello', u'15', u'guys']
A non-pythonic version would be:
input_list = [u'12', u'23', u'hello', u'15', u'guys']
non_numeric_found=False
res = []
for e in input_list:
if not non_numeric_found and e.isnumeric():
continue
non_numeric_found=True
res.append(e)
Any suggestion for a better implementation of this?
You can use
itertools.dropwhile: