From 29af6d42cc86faaa9efcacc266b98bd725df1fee Mon Sep 17 00:00:00 2001 From: slam <204929693+vailenz@users.noreply.github.com> Date: Thu, 27 Mar 2025 15:47:35 +0300 Subject: [PATCH] Simple Joke Generator Hello, I've made this simple joke generator to help & expand this repository --- simple_joke_generator.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 simple_joke_generator.py diff --git a/simple_joke_generator.py b/simple_joke_generator.py new file mode 100644 index 00000000..57cae149 --- /dev/null +++ b/simple_joke_generator.py @@ -0,0 +1,19 @@ +# importing the lib to request data from the API +import requests + +#this is the api for the joke generator +url = "https://v2.jokeapi.dev/joke/Any" + +#here is a request using the requests lib +request = requests.get(url) + +#now we make the data in .json +info = request.json() + +# if the joke has only one party then we run this statement +if 'joke' in info: + print(info['joke']) + +#if the joke has two parts then we run this statement +elif 'setup' in info and 'delivery' in info: + print(f"{info['setup']} - {info['delivery']}") \ No newline at end of file