Well, that should do it! It is even verified (thanks for sending more information).
>>> names = [trend["name"] for trend in retrieved[0]["trends"]]
>>> names
['#wishuwould', '#questionsidontlike', '#februarywish', 'Purp & Patron', 'Egyptians', 'Kool Herc', 'American Pie', 'Judge Vinson', 'Eureka Nutt', 'Eddie House']
I think that most of the confusion came from documentation referring to the result as a JSON object, which is different from a JSON string that needs to be converted using a module json.
How it works: retrieved- this is a list containing one element, which is a dictionary containing a key trends, therefore retrieved[0]["trends"]- this is a list of trend dictionaries, where each trend dictionary contains namewhich you are interested in.
source
share