You can download this code by clicking the button below.
This code is now available for download.
This function fetches a random quote from the https://api.quotable.io/random API and returns the quote content and author.
Technology Stack : Requests
Code Type : Function
Code Difficulty : Intermediate
import requests
import random
def get_random_quote():
url = 'https://api.quotable.io/random'
response = requests.get(url)
quote = response.json()
return quote['content'], quote['author']
def get_random_quote_and_share():
content, author = get_random_quote()
sharing_message = f"Here's a random quote for you: '{content}' - {author}"
return sharing_message