[Solved] Extracting a determined value from a list


You cannot perform a split directly on the list, you can only perform a split on a string (since the list is already split). So iterate over your list of strings and split each of them.

I will shorten the code to make it more readable, just replace it with your list.

strings = ['nbresets:0,totalsec:14,lossevtec:0,lossevt:0']
for s in strings:
    # first split by comma to get the single entries
    for line in s.split(','):
        params = line.split(':')
        if params[0] == 'totalsec':
            print(params[1]) # this should return 14

0

solved Extracting a determined value from a list