I have a 2 item list.
Sample inputs:
[\'19(1,B7)\', \'20(1,B8)\']
[\'16 Hyp\', \'16 Hyp\']
[\'< 3.2\', \'38.3302615548213\']
[\'18.6086945477694\
If you want to edit the list in place rather than create a new list, you can iterate over it using enumerate
:
for (list_index, item) in enumerate(values):
if '> ' in item:
values[list_index] = ' '.join(item_part for item_part in item.split() if is_number(item_part))
Or however you want to construct your new value - I'm not sure what you want if you have '5 6' in your original list.
If you want a new list, you can do something similar with a list comprehension.