<commit_before>from sys import exit
from logic import CapitalsQuiz, CountriesQuiz, RandomQuiz


class Quit:

    @staticmethod
    def quit():
        print("Ta ta for now!")
        exit()


class Loop:

    def loop(self):
        user_answer = input('> ').strip().lower()
        if user_answer == 'q':
            Quit.quit()
        elif self.quiz.is_right(user_answer):
            print("Yes! {} is the capital of {}! \n".format(self.capital, self.country))
        else:
            print("Nope. Try again.")
            self.loop()

    def start(self, debug=False):
        print(self.question)
        if debug:
            print("psst it's {}".format(self.quiz.correct_answer))
        self.loop()


class Capitals(Loop):

    def __init__(self):
        super(Capitals, self).__init__()
        self.quiz = CapitalsQuiz()
        self.capital = self.quiz.correct_answer
        self.country = self.quiz.hint
        self.question = "What is the capital of {}?".format(self.country)


class Countries(Loop):

    def __init__(self):
        super(Countries, self).__init__()
        self.quiz = CountriesQuiz()
        self.capital = self.quiz.hint
        self.country = self.quiz.correct_answer
        self.question = "What country is {} the capital of?".format(self.capital)



def switchboard():
    quiz_kind = input("Welcome to the Endless Capitals Quiz! Type 1 for Capitals, 2 for Countries, 3 for random, and Q to quit.\n >").strip().lower()
    if quiz_kind == 'q':
        Quit.quit()
    elif quiz_kind == '1':
        return Capitals
    elif quiz_kind == '2':
        return Countries
    elif quiz_kind == '3':
        randomly = RandomQuiz(Capitals, Countries)
        return randomly.choose
    else:
        print("Sorry didn't catch that.")
        switchboard()

if __name__ == '__main__':
    kind = switchboard()
    while True:
        quiz = kind()
        quiz.start(debug=True)
<commit_msg>simplified and working with new data and logic<commit_after>from sys import exit
from logic import Quiz


def intro():
    kind = input("What kind of quiz u want? Capitals, Countries, or Random? \n Q to quit, h for a hint (the answer)").lower().strip()

    if kind not in 'capitals countries random':
        raise ValueError("not a valid quiz type")

    def structure():
        quiz = Quiz(kind)

        debug = False

        if debug:
            print('ans: ' + quiz.ans)
            # print('  hint: ' + quiz.hint, end=' ')
            # print('  kind: ' + quiz.kind, end='\n')

        if quiz.kind == 'capitals':
            question = "What is the capital of {}?"

        if quiz.kind == 'countries':
            question = "{} is the capital of what country?"

        def loop():
            guess = input(question.format(quiz.hint)).lower().strip()

            if guess == 'q':
                exit()

            if guess == 'h':
                print(quiz.ans)
                loop()

            if quiz.is_correct(guess):
                print("Yes")
                inner()
            else:
                print("Try again")
                loop()

        loop()

    structure()

intro()



{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.0019083969465648854, 'mean_word_length': 1.9641847313854854, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6383791', 'n_tokens_mistral': 969, 'n_tokens_neox': 909, 'n_words': 267}