A simple Python script that fetches and displays 3 programming jokes using an API, JokeAPI, and HTTP requests.
- Fetches jokes from the JokeAPI Programming category
- Supports filtering out jokes containing specific keywords
- Displays up to 3 jokes before stopping
- Easy to customize for different joke types or categories
- Python 3.x
- requests library (
pip install requests
)
- Clone or download this repository.
- Open a terminal and navigate to the project directory.
- Run the script:
python jokes.py
- Enjoy your programming jokes!
- Change the joke category:
Edit theurl
infetch_joke()
to use a different category (e.g.,"https://v2.jokeapi.dev/joke/Any"
). - Filter out keywords:
Add keywords to theexclude_keywords
list in the main loop (e.g.,['sql', 'python']
). - Change the joke type:
Setjoke_type
to'twopart'
for two-part jokes.
Joke #1:
Category: Programming
Type: single
Joke: Why do programmers prefer dark mode? Because light attracts bugs.
Joke #2:
Category: Programming
Type: single
Joke: Why do Java developers wear glasses? Because they can't C#.
Joke #3:
Category: Programming
Type: single
Joke: How many programmers does it take to change a light bulb? None, that's a hardware problem.
Finished fetching 3 programming jokes!
Feel free to fork, modify, or submit pull requests!
Enjoy the jokes!