lundi 8 février 2021

How choose random quote using python from json 'api'?

I only start learning Python. For some reason with my Api random doesn't work. It's always showing the first quote.

def get_quote():
  response = requests.get("https://jlp-api.herokuapp.com/jlp-quotes")
  json_data = json.loads(response.text)
  quote = json_data[random.0]['q'] + " -" + json_data[random.0]['a']
  return(quote)


if msg.startswith('$inspire'):
    quote = get_quote()
    await message.channel.send(quote)



Aucun commentaire:

Enregistrer un commentaire