-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathup_down_game.py
More file actions
31 lines (28 loc) · 840 Bytes
/
up_down_game.py
File metadata and controls
31 lines (28 loc) · 840 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
import random
print("Let's figure out the number!")
opportunity = 7
answer = random.randrange(0, 101)
print("Opportunity : {}".format(opportunity))
try:
while opportunity > 0:
opportunity -= 1
question = input(" : ")
if int(question) > answer:
print("Down")
print("Opportunity : {}\n".format(opportunity))
elif int(question) < answer:
print("Up")
print("Opportunity : {}\n".format(opportunity))
if opportunity == 0:
print("Wasted.....")
print("The answer was {}".format(answer))
except ValueError:
print("="*30)
print("ValueError")
print("="*30)
except ZeroDivisionError as err:
print("="*30)
print("ZeroDivisionError")
print("="*30)
finally:
print("Thanks for using this game :D")