-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumber_Game.py
More file actions
32 lines (26 loc) · 864 Bytes
/
Copy pathNumber_Game.py
File metadata and controls
32 lines (26 loc) · 864 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
def game():
secret_num = random.randint(1, 10)
attempts = []
while len(attempts) < 5:
try:
guess_num = int(input("Enter a number between 1 and 10: "))
except ValueError:
print("This is not a number")
else:
# compare guess number to secret number
if not guess_num == secret_num:
if guess_num > secret_num:
print("Number is TOO HIGH")
else:
print("Number is TOO LOW")
attempts.append(guess_num)
elif guess_num == secret_num:
print("You got the number correct it was {} ".format(secret_num))
else:
again = input("Do you want to play again? y/n")
if again == "y":
game()
else:
print("Bye")
game()