Skip to content

Commit

Permalink
Merge pull request #664 from mmakrin/patch-1
Browse files Browse the repository at this point in the history
Update guess_number.py
  • Loading branch information
Mrinank-Bhowmick authored Dec 26, 2023
2 parents 435cd4c + 13cecef commit dbf9e46
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions projects/Guess Number/guess_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
larger_number = 10
upper_limit = 10
lower_limit = 1
num_of_guesses=0


# function to prompt user for input. will continue to ask user for proper int if invalid num passed
Expand Down Expand Up @@ -35,13 +36,16 @@ def guess(num, user_guess):
print(f"\nNumber is higher than {user_guess}")
lower_limit = user_guess
user_guess = enter_and_verification(lower_limit + 1, upper_limit)
num_of_guesses++
elif num < user_guess:
print(f"\nNumber is lower than {user_guess}")
upper_limit = user_guess
user_guess = enter_and_verification(lower_limit, upper_limit - 1)
num_of_guesses++
else:
print()
print(f"\nCongrats! You've guessed the correct number! It was {num}.\n")
print("\nYou have tried {num_of_guesses} times to find the number.\n")


# while loop to prompt user to play intially, then continue to play or not
Expand Down

0 comments on commit dbf9e46

Please sign in to comment.