Skip to content

Commit

Permalink
Merge pull request #704 from ThanasisNov/main
Browse files Browse the repository at this point in the history
Fixed the Issue  #650
  • Loading branch information
Mrinank-Bhowmick committed Feb 19, 2024
2 parents 8eb6455 + 5a086ce commit 165b62b
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions projects/Higher-Lower/main.py
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.")




0 comments on commit 165b62b

Please sign in to comment.