Created
October 22, 2021 11:10
-
-
Save Diacius/49b1eb3467b7b6d6cf0899f8f8fefed2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# jokeapi https://v2.jokeapi.dev/joke/Any?blacklistFlags=nsfw,religious,political,racist,sexist,explicit | |
import requests | |
import json | |
from time import sleep | |
points = 0 | |
for i in range(5): | |
joke =requests.get("https://v2.jokeapi.dev/joke/Programming?blacklistFlags=nsfw,religious,political,racist,sexist,explicit&type=twopart") | |
jokeJSON = str(joke.text) | |
joke = json.loads(jokeJSON) | |
#DEBUG: print(jokeJSON) | |
print("Welcome to the jokebox see if you can guess the puchline!") | |
print(joke["setup"]) | |
guess = input("Guess the punchline:") | |
if guess == joke["delivery"]: | |
print("Well done you guessed it :) \n The full joke is:") | |
print("Q: " + joke["setup"]) | |
sleep(1) | |
print("A: " + joke["delivery"]) | |
sleep(1) | |
print("You get a point!") | |
points = points + 1 | |
else: | |
print("You didn't guess correctly :( \n The full joke is:") | |
print("Q: " + joke["setup"]) | |
sleep(1) | |
print("A: " + joke["delivery"]) | |
print("You got:") | |
sleep(1) | |
print(str(points) + " Points!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I PARSED JSON IN PYTHON!