Use NamedTuple; Fix camelCase->snake_case

This commit is contained in:
Martin Thoma
2022-04-02 11:21:11 +02:00
parent ac184fec42
commit e17388d072
13 changed files with 167 additions and 178 deletions

View File

@@ -6,18 +6,17 @@ A children's literature quiz
Ported by Dave LeCompte
"""
from typing import List, NamedTuple
PAGE_WIDTH = 64
class Question:
def __init__(
self, question, answer_list, correct_number, incorrect_message, correct_message
):
self.question = question
self.answer_list = answer_list
self.correct_number = correct_number
self.incorrect_message = incorrect_message
self.correct_message = correct_message
class Question(NamedTuple):
question: str
answer_list: List[str]
correct_number: int
incorrect_message: str
correct_message: str
def ask(self) -> bool:
print(self.question)
@@ -69,7 +68,6 @@ questions = [
def print_centered(msg: str) -> None:
spaces = " " * ((64 - len(msg)) // 2)
print(spaces + msg)