[Solved] How can I loop through a data structure? [closed]


I believe it should just be a couple of small typos. First, your second line looks like it should be indented, and where you have links["property"], it looks like you would want link["property"].

for link in links:
    payload[f'Links[{link["property"]}][url]'] = link['url']

The reason it is giving you that error is that you are trying to get the "property" attribute of links, which is some iterable data structure like a list, and you would index those with an integer (links[3]) or slice (links[1:]) for example.

solved How can I loop through a data structure? [closed]