Apr-22-2020, 10:13 AM
data
is the dictionary. When you do for element in data
, element takes on the value of the key, first iteration, it is 'sentence', second iteration, it is 'tags' Get rid of the for loop and it will work.import json data = json.loads('{"sentence": ["what", "is", "a", "transistor"],"tags": ["WH", "AUX", "DT", "NN"]}') print(type(data)) print(data["sentence"]) sents = [] tags = [] sents.append(data['sentence']) tags.append(data['tags'])