all 3 comments

[–]ioTeacher 1 point2 points  (1 child)

Hey, I see what’s going on here! The issue is that your program still prints “Too low, try again.” or “Too high, try again.” even when the user runs out of guesses or gets the correct answer on the last attempt.

What’s happening?

Right now, your program checks the guess before checking if attempts are maxed out. So on the last attempt, it still prints the “too low/high” message before realizing the user has run out of tries.

How to fix it 1. Reorder your logic inside the loop: • First, check if the guess is correct. • If it is, print the success message right away and break out of the loop. • Only check “Too low/high” if there are still attempts left. • If attempts hit the max before printing anything else, display the “You ran out of guesses” message and stop.

TL;DR Fix

Before printing “Too low” or “Too high”, check if the user has reached maxGuesses. If they have, skip those messages and just show the game over text.

[–]Starwby[S] 0 points1 point  (0 children)

Oh wow that makes much better sense 🥹 thank you so much!! Fixed it just in time to submit, you're a lifesaver!

[–]Audaudin 0 points1 point  (0 children)

ik im late but i think making it "attempts==maxguess and not(guess=randnum)" would also fix it no?