Skip to content

Commit

Permalink
fixed the issue #650
Browse files Browse the repository at this point in the history
  • Loading branch information
ThanasisNov committed Feb 11, 2024
1 parent 8eb6455 commit 5a086ce
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 5a086ce

Please sign in to comment.