import json from random import randrange # Einlesen vom Json File def read_json(filename): with open(filename,encoding='utf-8') as filename: data = json.load(filename) return data # Zufällige Frage erstellen def random_question(filename): min_ = 0 max_ = len(read_json(filename)) random_number = randrange(min_,max_) questions = read_json(filename) question = f'Frage #{random_number}: ' + questions[random_number][str(random_number)]['question'] answer = questions[random_number][str(random_number)]['answer'] return question, answer #print(random_question(config.json_file)[0])