From 7ab59915347b9181556fc4b9d9cca9f249ce7ff8 Mon Sep 17 00:00:00 2001 From: hikarikumo Date: Sun, 17 Dec 2023 19:16:21 +0200 Subject: [PATCH] revert Signed-off-by: hikarikumo --- brain_games/prime_game.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/brain_games/prime_game.py b/brain_games/prime_game.py index ed11fd2..7cf484e 100644 --- a/brain_games/prime_game.py +++ b/brain_games/prime_game.py @@ -3,6 +3,13 @@ from cli import greet_first, welcome_user +def question_prime(): + """Ask the question and return a tuple (number_to_guess, user_answer).""" + number_to_guess = random.randint(1, 100) + user_answer = prompt.string(f'Number: {number_to_guess}\n') + return number_to_guess, user_answer + + def prime_goal(): """Provide information about the goal of the prime game to the user.""" print('Answer "yes" if given number is prime. Otherwise answer "no".\n') @@ -17,8 +24,7 @@ def is_prime(number): def prime_game(name): """Brain game prime logic.""" for _ in range(3): - random_number = random.randint(1, 100) - user_answer = prompt.string(f'Number: {random_number}\n') + random_number, user_answer = question_prime() prime_status = is_prime(random_number) expected_answer = 'yes' if prime_status else 'no'