forked from Mrinank-Bhowmick/python-beginner-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
23 lines (20 loc) · 705 Bytes
/
main.py
File metadata and controls
23 lines (20 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from random import randint
print("Welcome to the Higher-Lower Game!")
rnum = randint(0, 100)
noguesses = 0
while True:
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.")