-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumber_guess.py
More file actions
36 lines (29 loc) · 882 Bytes
/
number_guess.py
File metadata and controls
36 lines (29 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import random
top_range = input("type of range : ")
if top_range.isdigit():
top_range =int(top_range)
if top_range <= 0:
print("please enter the values greater than zero")
quit()
else:
print("plaese enter valid number and try again : ")
quit()
random_number = random.randint(0,top_range)
#print(random_number)
guess =0
while True:
guess +=1
users_guess = input(" make guess the number : ")
if users_guess.isdigit():
users_guess = int(users_guess)
else:
print("guess missed numbers : ")
continue
if users_guess ==random_number:
print("you got it ")
break
elif users_guess >random_number:
print("you are guessing the above number ")
else:
print("you are guessing the below numbers : ")
print(f"you are guessing the number in how mant {guess} times ")