Paste element using json python

-1

I am using the following code to try to get what is written inside definition , located in list

import requests
import json
word = "salut"
page = requests.get("http://api.urbandictionary.com/v0/define?term=" + word)
gotcha = page.json()
print(gotcha.get("list"))

But the problem is that I can not actually collect the string within definition

[{'definition': 'Informal French greeting, equivalent to the English "hi."', 'permalink': 'http://salut.urbanup.com/1076339', 'thumbs_up': 186, 'author': 'WeluvTwinkie', 'word': 'Salut', 'defid': 1076339, 'current_vote': '', 'example': '"Hey, there!"\r\n"Salut!"', 'thumbs_down': 28}, {'definition': 'A sly way of pronouncing the word [slut]; used to describe pretty, [nympho] ballerinas.', 'permalink': 'http://sa-lut.urbanup.com/1152075', 'thumbs_up': 13, 'author': 'Sheeba', 'word': 'Sa-lut', 'defid': 1152075, 'current_vote': '', 'example': 'My saaaaa-lut: Scott Lloyd Forward', 'thumbs_down': 57}]
    
asked by anonymous 10.01.2018 / 22:36

1 answer

1

In this case you have a dictionary. You can use a for to traverse the vector and read each item by the key. Save this list to a variable, var and print:

for v in var: print(v['definition'])

    
12.01.2018 / 14:20