(num, user_guess, num_of_guesses)
| 35 | |
| 36 | # function to handle checking user input against random number and upper/lower bounds |
| 37 | def guess(num, user_guess, num_of_guesses): |
| 38 | upper_limit = 10 |
| 39 | lower_limit = 1 |
| 40 | while num != user_guess: |
| 41 | if num > user_guess: |
| 42 | print(f"\nNumber is higher than {user_guess}") |
| 43 | lower_limit = user_guess |
| 44 | user_guess = enter_and_verification(lower_limit + 1, upper_limit) |
| 45 | num_of_guesses = num_of_guesses + 1 |
| 46 | elif num < user_guess: |
| 47 | print(f"\nNumber is lower than {user_guess}") |
| 48 | upper_limit = user_guess |
| 49 | user_guess = enter_and_verification(lower_limit, upper_limit - 1) |
| 50 | num_of_guesses = num_of_guesses + 1 |
| 51 | else: |
| 52 | print() |
| 53 | print(f"\nCongrats! You've guessed the correct number! It was {num}.\n") |
| 54 | print(f"\nYou have tried {num_of_guesses+1} times to find the number.\n") |
| 55 | |
| 56 | |
| 57 | # while loop to prompt user to play intially, then continue to play or not |
no test coverage detected