from jokeapi import Jokes # Import the Jokes class j = Jokes() # Initialise the class joke = j.get_joke(category=['programming', 'dark']) # Retrieve a random joke if joke["type"] == "single": # Print the joke print(joke["joke"]) else: print(joke["setup"]) print(joke["delivery"])