I've been researching this for hours now and can't figure out how to get this to work. I have a JSON data file with three categories in every item: deck, description, and name. I'm trying to draw the "name" value for every item 0 - 99 and that save that data to a text file.
I cannot for the life of me figure how how I'm supposed to do it. I load in the data easily enough, and I can print out an individual value with this:
with open('gbdata1.json', 'r') as gbdata1:
data = json.load(gbdata1)
print(data['results'][0]['name'])
I've tried passing it a list of the numbers I needed:
names = [0, 1, 2, 3, 4, 5]
for item in data['results'][names]['name']:
print(item)
but it says:
TypeError: list indices must be integers or slices, not list
So I tried creating a variable and then just incrementing the variable with a forloop and the += operator, but that didn't work either. I'm a total JSON newbie so if I'm overlooking something very obvious.