-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguessgame.py
More file actions
33 lines (27 loc) · 784 Bytes
/
guessgame.py
File metadata and controls
33 lines (27 loc) · 784 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
import random
top_of_range = input ('Type a number to be top of range: ')
if top_of_range.isdigit():
top_of_range = int(top_of_range)
if top_of_range <= 0:
print('type a number larger than 0 next time')
quit()
else:
print ('please type a number next time')
quit()
random_number = random.randint(0,top_of_range)
guesses =0
while True:
guesses +=1
user_guess= input ('make a guess: ')
if user_guess.isdigit():
user_guess = int(user_guess)
else :
print('please print a number next time')
continue
if user_guess == random_number:
print('correct!')
break
elif user_guess > random_number :
print ('you are obove the number')
else:
print('You are below the number')