This Python script generates jokes by fetching data from the icanhazdadjoke API. It utilizes the requests
library to make HTTP requests and retrieve jokes in JSON format.
- Clone the repository or download the
code.py
file. - Make sure you have Python installed on your system.
- Run the script using the following command:
python code.py
Dependencies This script requires the requests library, which can be installed via pip:
Copy code
pip install requests
How it works
The script sends a GET request to the icanhazdadjoke API and receives a response containing a joke in JSON format. It then extracts the joke from the JSON data and prints it to the console.
Error Handling If there is an error fetching the data from the API, the script will display an error message and prompt the user to try again.
https://devfolio.co/projects/jokes-generator-open-innovation-6bb5