In this we are using pyjokes which is a python library used to get jokes for programmers. We can also call it as a fun python library that can be used simply with some lines of code.
Note: It requires proper Internet connection for its working.
Install with pip using any terminal
pip install pyjokes
Import the pyjokes
module in the Python file that you are going to get the jokes and then use the get_joke()
function to easily get a random joke into your console/application.
import pyjokes
joke = pyjokes.get_joke()
print(joke)
To get jokes in a specific language and for a particular category though there are not many categories and language but we can use those that are available.
import pyjokes
joke = get_joke(language="es",category="neutral")
print(joke)
Value | Language Name |
---|---|
en | English |
de | German |
es | Spanish |
it | Italian |
gl | Galician |
eu | Basque |
Value | Category Detail |
---|---|
neutral | Neutral geeky jokes |
twister | Tongue-twister |
all | All types of joke |