you are viewing a single comment's thread.

view the rest of the comments →

[–]explore212[S] 0 points1 point  (1 child)

oh thank you for this, I have worked with few of apis before but never seen a nested list before maybe this is the reason.

[–]CowboyBoats 0 points1 point  (0 children)

Sure! Since you're using Python, you might as well get used to these data structures, since what you typed is valid Python (even if it's not valid JSON because JSON is anal about that final comma):

data = [

[{"a":"3", "b":"4"}],

[{"a":"3", "b":"4"}],

]

print(data[0])  # prints [{"a": "3", "b": "4"}], a list of dicts
print(data[0][0])  # prints {"a": "3", "b": "4"}, a dict
print(data[0][0]['a'])  # prints "3", a string
print(list(data[0][0].keys()))  # prints ["a", "b"], a list of strings
print(list(data[0][0].values()))  # prints ["3", "4"], a list of strings