From 2f03118cfa657ee2a5ba1db77ca7440ae52b1f75 Mon Sep 17 00:00:00 2001 From: Loris TICHADOU <loris.tichadou@ensiie.fr> Date: Wed, 7 Aug 2019 14:11:23 +0200 Subject: [PATCH] Update quizz.py --- quizz.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/quizz.py b/quizz.py index f95d188..5268800 100644 --- a/quizz.py +++ b/quizz.py @@ -6,15 +6,16 @@ from random import shuffle def quizz() : req = requests.get("https://opentdb.com/api.php?amount=1&difficulty=easy") al = req.json() + pas_reponse = [] rep= al['results'][0] - question = rep['question'] - reponse= rep['correct_answer'] + question = urllib.unquote(rep['question']) + reponse= urllib.unquote(rep['correct_answer']) choix = [reponse.encode('utf8')] for f in rep['incorrect_answers'] : urllib.unquote(f) + pas_reponse.append(f.encode('utf8')) choix.append(f.encode('utf8')) shuffle(choix) - return {'question' : question.encode('utf8'), 'reponse' : reponse.encode('utf8'), 'choix' : choix} - + return {'question' : question.encode('utf8'), 'reponse' : reponse.encode('utf8'), 'choix' : choix, 'pas_reponse' : pas_reponse } -- GitLab