-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path88.py
24 lines (21 loc) · 878 Bytes
/
88.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#Guess the number game.
print("Jaber: Hey there, are you interested in playing a number guessing game?")
print("Kabir: Yeah, sure. Provide me a range to guess?")
print("Jaber: Guess a number between 1 to 20. If you guess it right, I have a gift for you.")
number = int(input("Kabir: I am guessing: "))
count = 0
while True:
thresold = 14
if number >= 0 and number < thresold:
number = int(input("Kabir: Your guess is too low. Guess again: "))
count += 1
elif number > thresold and number <=20:
number = int(input("Kabir: Your guess is too high. Guess again: "))
count += 1
elif number == thresold:
count +=1
print("Kabir: Your guess is correct. You guessed my number in "+ str(count)+ " guess(es).")
break
else:
number = int(input("Kabir: Invalid. Guess again: "))
count += 1