From 913136321c9d904a48d0ce5b1246b31ddbe7816a Mon Sep 17 00:00:00 2001 From: Serhii Horodilov Date: Sat, 14 Oct 2023 12:49:04 +0300 Subject: [PATCH] Implement display question function --- src/quiz/func.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/quiz/func.py b/src/quiz/func.py index f2c6198..ab7b6a3 100644 --- a/src/quiz/func.py +++ b/src/quiz/func.py @@ -15,6 +15,7 @@ from __future__ import annotations import csv +import logging from typing import List, TYPE_CHECKING, TypedDict, Union if TYPE_CHECKING: @@ -27,6 +28,9 @@ }) Questions = List[Question] +logging.basicConfig(level=logging.INFO, format="%(message)s") +logger = logging.getLogger("quiz") + # noinspection PyTypeChecker def load_questions_from_file(source: Union[str, pathlib.Path]) -> Questions: @@ -64,6 +68,10 @@ def display_question(question: Question) -> None: """ + logger.info("%s\n" % question["question"]) + for opt_idx, option in enumerate(question["options"], 1): + logger.info("%d: %s" % (opt_idx, option)) + def gather_answer(question: Question) -> int: """