A quick help on python dict

Hi Team,
I'm new to python and working on a project.
I have an API call which returns a dict(got the dict.values() and converted to list) as shown below:

dict_values([OffsetAndMetadata(offset=66, metadata=''), OffsetAndMetadata(offset=107, metadata=''), OffsetAndMetadata(offset=189, metadata='')])

Any clue, how can I get only offset values, in deed I need a sum of those. I can write a "shell sed command" inside python and using os.command can get the work done, but looking for a cleaner python solution/hint.
Thanks,
Ravi

1 Like

Hi,

Managed to find a solution within python. Can be closed.

for item in dict.values():
            currentOffset+=int(str(item).partition("offset")[2].partition("metadata")[0].replace('=','').replace(',',''))        

thnx

Thanks for sharing and pleased you found by yourself a suitable solution