From 68ae00ca28ad41887c2e925cb83bc628568f81ef Mon Sep 17 00:00:00 2001 From: Vinicius Santos Date: Fri, 28 Nov 2025 21:08:44 -0300 Subject: [PATCH] Fix score update logic in next_colour function Updated the next_colour function to strip user input and ensure score updates correctly even when the user enters an incorrect color. --- Color_Game/main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Color_Game/main.py b/Color_Game/main.py index 4d1e68d9..48cfd72f 100644 --- a/Color_Game/main.py +++ b/Color_Game/main.py @@ -6,13 +6,14 @@ score = 0 timeleft = 30 +# BUG: Score doesn't update when user enters wrong color +# FIX: def next_colour(): global score, timeleft - if timeleft > 0: - user_input = e.get().lower() + user_input = e.get().strip().lower() correct_color = colours[1].lower() - + if user_input == correct_color: score += 1 @@ -20,8 +21,6 @@ def next_colour(): random.shuffle(colours) label.config(fg=colours[1], text=colours[0]) score_label.config(text=f"Score: {score}") - - def countdown(): global timeleft if timeleft > 0: @@ -96,4 +95,5 @@ def start_game(event): e.focus_set() -window.mainloop() \ No newline at end of file + +window.mainloop()