Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
532 B
1
Indexable
Never
def read_quiz_file(file_name):
    quiz_dict = {}
    with open(file_name, 'r', encoding="KOI8-R") as f:
        for line in f:
            if line.strip() == '':
                continue
            if line.startswith('Вопрос'):
                question_number = line.split(' ')[1].strip()
                quiz_dict[f"Вопрос({question_number})"] = ""
            elif line.startswith('Ответ'):
                quiz_dict[f"Вопрос({question_number})"] += line.split(':')[1].strip() + '\n'

    print(quiz_dict)
Leave a Comment