So I am trying to get a random value from the data that i get from gyphi api search. I tried this: `
import giphy_client
import time
import random
from pprint import pprint
api_instance = giphy_client.DefaultApi()
api_key = "aqMkX2XKd7aCTM4pVRB7XXXXXX9ieep"
q = "banana"
api_response = api_instance.gifs_search_get(api_key, q)
pprint(random.choice(api_response))`
But it returns error: TypeError: object of type 'InlineResponse200' has no len()
And I have no idea what to do.
Sorry if this is dumb question, but I am new and couldn’t find the answer anywhere
api_response
is of type InlineResponse200
.
Here is its spec: https://github.com/Giphy/giphy-python-client/blob/master/docs/InlineResponse200.md
What you want is the data contained in this response, so you should do:
pprint(random.choice(api_response.data))