I'm fairly new to Python and JSON, and I'm having a bit of trouble parsing through this data:
{
"tests":
[
{"array": [-21, 301, 12, 4, 65, 56, 210, 356, 9, -47], "target": 163},
{"array": [-21, 301, 12, 4, 65, 56, 210, 356, 9, -47], "target": 164},
{"array": [1, 2, 3, 4, 5, 6, 7, 8, 9, 15], "target": 18},
{"array": [-7, -5, -3, -1, 0, 1, 3, 5, 7], "target": -5},
{"array": [3, 5, -4, 8, 11, 1, -1, 6], "target": 10},
{"array": [1, 2, 3, 4, 5, 6, 7, 8, 9], "target": 17},
{"array": [3, 5, -4, 8, 11, 1, -1, 6], "target": 15},
{"array": [4, 6, 1, -3], "target": 3},
{"array": [4, 6, 1], "target": 5},
{"array": [4, 6], "target": 10},
{"array": [14], "target": 15},
{"array": [15], "target": 15}
]
}
This is what's inside of the file, and if I understand correctly, this is a dictionary ("tests":) with dictionaries inside of it that are comma-separated, where each dictionary has a kvp of array:list, target:int. Please correct me if I am wrong on this part.
Now, what I'm trying to do is loop through each of the dictionaries and print the list then integer of each. So far, this is what I have in Python:
for array, target_sum in test_data['tests']:
print(array, target_sum)
but all I'm printing out is this:
array target array target array target array target array target array target array target array target array target array target array target array target
I guess what I'm trying to ask is how to print the values of this instead of the keys. Any help is appreciated, sorry for the noob question.