A Python library to fetch dad jokes from a list of 3000 jokes.
You can install JokeMachine via pip:
pip install JokeMachinefrom JokeMachine import Dad_Joke
# Fetch a random dad joke
setup, punchline = Dad_Joke()
print(setup)
print(punchline)
# Fetch a random dad joke and print the full joke
full_joke = Dad_Joke(full=True)
print(full_joke)Fetches a random dad joke from the API.
Arguments
full(bool, optional): IfTrue, returns the full joke with a newline between setup and punchline.striffullisNone: The full joke as a single string with a newline between setup and punchline.Noneif the request fails or no jokes are available.
Returns
TupleiffullisNone(Default): A tuple representing the random joke fetched from the API, containing the setup (str) and punchline (str).striffullisTrue: The full joke as a single string with a newline between setup and punchline.- None if the request fails or no jokes are available.
requests
Sarah Andersson
- Email Ripsweetener@gmail.com