-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguessinggame.py
More file actions
26 lines (23 loc) · 764 Bytes
/
guessinggame.py
File metadata and controls
26 lines (23 loc) · 764 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
import random
highest = 1000
answer = random.randint(1, highest)
print(answer) # TODO: Remove after testing
guess = 0 # initialize to any number that doesn't equal the answer
print("Please guess a number between 1 and {}: ".format(highest))
while guess != answer:
guess = int(input())
if guess == 0:
break
if guess == answer:
print("Well done, you guessed it")
break
else:
if guess < answer:
print("Please guess higher")
else: # guess must be greater than answer
print("Please guess lower")
# guess = int(input())
# if guess == answer:
# print("Well done, you guessed it")
# else:
# print("Sorry, you have not guessed correctly")