forked from Mrinank-Bhowmick/python-beginner-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed the issue Mrinank-Bhowmick#650
- Loading branch information
1 parent
8eb6455
commit 5a086ce
Showing
1 changed file
with
22 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,26 @@ | ||
from random import randint | ||
|
||
print("Welcome to the Higher-Lower Game!") | ||
rnum = randint(0, 100) | ||
noguesses = 0 | ||
while True: | ||
guess = int(input(": ")) | ||
if guess > rnum: | ||
print("Lower") | ||
elif guess < rnum: | ||
print("Higher") | ||
else: | ||
(print("You win ({noguesses} guesses used)"), quit()) | ||
noguesses += 1 | ||
|
||
while True: | ||
guess = input("Guess the number: ") | ||
if guess.isdigit(): | ||
# Check if the input string consists of digits only | ||
integer_number = int(guess) | ||
print("You entered:", integer_number) | ||
|
||
if integer_number > rnum: | ||
print("Lower") | ||
elif integer_number < rnum: | ||
print("Higher") | ||
else: | ||
(print("You win! the number is " +guess+"!"), quit()) | ||
noguesses += 1 | ||
else: | ||
print("Invalid input. Please enter an integer number.") | ||
|
||
|
||
|
||
|