from flask import Blueprint, jsonify  # jsonify creates an endpoint response object
from flask_restful import Api, Resource # used for REST API building
import requests  # used for testing

url = "https://opentdb.com/api.php?amount=10&category=19&difficulty=medium&type=multiple"
response = requests.request("GET", url)
quiz_data = response

print(quiz_data.text)
{"response_code":0,"results":[{"category":"Science: Mathematics","type":"multiple","difficulty":"medium","question":"In the hexadecimal system, what number comes after 9?","correct_answer":"The Letter A","incorrect_answers":["10","The Number 0","16"]},{"category":"Science: Mathematics","type":"multiple","difficulty":"medium","question":"How many zeros are there in a googol?","correct_answer":"100","incorrect_answers":["10","1,000","1,000,000"]},{"category":"Science: Mathematics","type":"multiple","difficulty":"medium","question":"What is the first Mersenne prime exponent over 1000?","correct_answer":"1279","incorrect_answers":["2203","1009","1069"]},{"category":"Science: Mathematics","type":"multiple","difficulty":"medium","question":"What is the alphanumeric representation of the imaginary number?","correct_answer":"i","incorrect_answers":["e","n","x"]},{"category":"Science: Mathematics","type":"multiple","difficulty":"medium","question":"To the nearest whole number, how many radians are in a whole circle?","correct_answer":"6","incorrect_answers":["3","4","5"]},{"category":"Science: Mathematics","type":"multiple","difficulty":"medium","question":"What Greek letter is used to signify summation?","correct_answer":"Sigma","incorrect_answers":["Delta","Alpha","Omega"]},{"category":"Science: Mathematics","type":"multiple","difficulty":"medium","question":"Which greek mathematician ran through the streets of Syracuse naked while shouting "Eureka" after discovering the principle of displacement?","correct_answer":"Archimedes","incorrect_answers":["Euclid","Homer","Eratosthenes"]},{"category":"Science: Mathematics","type":"multiple","difficulty":"medium","question":"How many books are in Euclid's Elements of Geometry?","correct_answer":"13","incorrect_answers":["8","10","17"]},{"category":"Science: Mathematics","type":"multiple","difficulty":"medium","question":"Which of the following dice is not a platonic solid?","correct_answer":"10-sided die","incorrect_answers":["12-sided die","20-sided die","8-sided die"]},{"category":"Science: Mathematics","type":"multiple","difficulty":"medium","question":"Which mathematician refused the Fields Medal?","correct_answer":"Grigori Perelman","incorrect_answers":["Andrew Wiles","Terence Tao","Edward Witten"]}]}
print(quiz_data.json())
{'response_code': 0, 'results': [{'category': 'Science: Mathematics', 'type': 'multiple', 'difficulty': 'medium', 'question': 'In the hexadecimal system, what number comes after 9?', 'correct_answer': 'The Letter A', 'incorrect_answers': ['10', 'The Number 0', '16']}, {'category': 'Science: Mathematics', 'type': 'multiple', 'difficulty': 'medium', 'question': 'How many zeros are there in a googol?', 'correct_answer': '100', 'incorrect_answers': ['10', '1,000', '1,000,000']}, {'category': 'Science: Mathematics', 'type': 'multiple', 'difficulty': 'medium', 'question': 'What is the first Mersenne prime exponent over 1000?', 'correct_answer': '1279', 'incorrect_answers': ['2203', '1009', '1069']}, {'category': 'Science: Mathematics', 'type': 'multiple', 'difficulty': 'medium', 'question': 'What is the alphanumeric representation of the imaginary number?', 'correct_answer': 'i', 'incorrect_answers': ['e', 'n', 'x']}, {'category': 'Science: Mathematics', 'type': 'multiple', 'difficulty': 'medium', 'question': 'To the nearest whole number, how many radians are in a whole circle?', 'correct_answer': '6', 'incorrect_answers': ['3', '4', '5']}, {'category': 'Science: Mathematics', 'type': 'multiple', 'difficulty': 'medium', 'question': 'What Greek letter is used to signify summation?', 'correct_answer': 'Sigma', 'incorrect_answers': ['Delta', 'Alpha', 'Omega']}, {'category': 'Science: Mathematics', 'type': 'multiple', 'difficulty': 'medium', 'question': 'Which greek mathematician ran through the streets of Syracuse naked while shouting "Eureka" after discovering the principle of displacement?', 'correct_answer': 'Archimedes', 'incorrect_answers': ['Euclid', 'Homer', 'Eratosthenes']}, {'category': 'Science: Mathematics', 'type': 'multiple', 'difficulty': 'medium', 'question': 'How many books are in Euclid's Elements of Geometry?', 'correct_answer': '13', 'incorrect_answers': ['8', '10', '17']}, {'category': 'Science: Mathematics', 'type': 'multiple', 'difficulty': 'medium', 'question': 'Which of the following dice is not a platonic solid?', 'correct_answer': '10-sided die', 'incorrect_answers': ['12-sided die', '20-sided die', '8-sided die']}, {'category': 'Science: Mathematics', 'type': 'multiple', 'difficulty': 'medium', 'question': 'Which mathematician refused the Fields Medal?', 'correct_answer': 'Grigori Perelman', 'incorrect_answers': ['Andrew Wiles', 'Terence Tao', 'Edward Witten']}]}
results = quiz_data.json().get('results')

def IndividualQuestion(a):
    a = results
    count = 0
    for i in a:
        q = results[count]
        count += 1
        print(q['question'])

IndividualQuestion(results)

#print(results[1])
#question_1 = results[1]

#print(question_1["question"])
In the hexadecimal system, what number comes after 9?
How many zeros are there in a googol?
What is the first Mersenne prime exponent over 1000?
What is the alphanumeric representation of the imaginary number?
To the nearest whole number, how many radians are in a whole circle?
What Greek letter is used to signify summation?
Which greek mathematician ran through the streets of Syracuse naked while shouting "Eureka" after discovering the principle of displacement?
How many books are in Euclid's Elements of Geometry?
Which of the following dice is not a platonic solid?
Which mathematician refused the Fields Medal?