Q:

Accessing the list of list specific number elements and merging using python

I have a list of list elements in that i have to access specific number elements and merge them using python code.
I have tried using list Comprehension but it is not working.
myList = [['a:', 'b:', '4,80', 'c:', 'b:', '5,00', ':', '4,91', 'Pass'], ['a:', 'b:', '1,45', 'c:', 'b:', '1,55', 'd:', '1,51', 'Pass'], ['a:', 'b:', '-1,15', 'a:', 'b:', '-0,95', 'c:', '-1,07', 'Pass']]
test = [myList [i] for i in [2,5,7]]
            str1 = ''.join(test)
            remove = int(str1.replace(',',''))
            add_commas= "{:,}".format(remove)
            conv_list = add_commas.split(',')
            ac,ll,ut = conv_list[0],conv_list[1],conv_list[2]
            print(ac,ll,ut)

The expected output should be:
[[480,500,491],[145,155,151],[-115,-095,-107]]

A:

If you gather up just the characters you want, then you can return them with a function like:
GOOD_CHARS = set('0123456789-+')

def to_number(num_str):
    return ''.join(c for c in num_str if c in GOOD_CHARS)

Then if you drop any empty strings you will get what you are after.
Test Code:
my_list = [['a:', 'b:', '4,80', 'c:', 'b:', '5,00', ':', '4,91', 'Pass'],
          ['a:', 'b:', '1,45', 'c:', 'b:', '1,55', 'd:', '1,51', 'Pass'],
          ['a:', 'b:', '-1,15', 'a:', 'b:', '-0,95', 'c:', '-1,07', 'Pass']]

print([[int(to_number(x)) for x in row if to_number(x)] for row in my_list])

Results:
[[480, 500, 491], [145, 155, 151], [-115, -95, -107]]

