File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 11from brain_games .cli import welcome_user
22
3- def start_game (description , generate_question ):
3+ def start_game (description , question_func ):
44 user_name = welcome_user ()
55 print (description )
6- ROUNDS_TO_WIN = 3
76
8- for _ in range (ROUNDS_TO_WIN ):
9- question , correct_answer = generate_question ()
7+ rounds_to_win = 3
8+ for _ in range (rounds_to_win ):
9+ question , correct_answer = question_func ()
1010 print (f"Question: { question } " )
11- user_answer = input ("Your answer: " ).strip (). lower ()
11+ user_answer = input ("Your answer: " ).strip ()
1212
13- if user_answer != correct_answer :
13+ if user_answer != str ( correct_answer ) :
1414 print (
1515 f"'{ user_answer } ' is wrong answer ;(. "
16- f"Correct answer was '{ correct_answer } '."
17- )
16+ f"Correct answer was '{ correct_answer } '." )
1817 print (f"Let's try again, { user_name } !" )
1918 break
19+ else :
20+ print ("Correct!" )
21+
2022 else :
2123 print (f"Congratulations, { user_name } !" )
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ def main():
66 start_game (
77 "What is the result of the expression?" ,
88 generate_calculation
9- )
9+ )
1010
1111
1212if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments