0

I have following python code

if b in q:
    print "id:",data['id']
    print "quest:",q
    print "result:",qa['terms'][0]
neusch
  • 11
  • 5

1 Answers1

0

If I understand correctly, start with something like this

You need to form a dictionary, not simply print the values as you get them

import json

output = []

# Some code...

if b in q:
    _data = dict()
    _data["id"] = data['id']
    _data["quest"] = q
    _data["result"] = qa['terms'][0]
    output.append(_data)

print json.dumps(output)
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245