-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest8.py
More file actions
26 lines (23 loc) · 696 Bytes
/
test8.py
File metadata and controls
26 lines (23 loc) · 696 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
inclusive_range = (1, 20)
print("Guess number that is between %i and %i .\n"
% inclusive_range)
target = random.randint(*inclusive_range)
answer, i = None, 0
while answer != target:
i += 1
txt = input("Your guess(%i): " % i)
try:
answer = int(txt)
except ValueError:
print(" I don't understand your input of '%s' ?" % txt)
continue
if answer < inclusive_range[0] or answer > inclusive_range[1]:
print(" Out of range!")
continue
if answer == target:
print(" PINGWIN-> YOU WIN!!")
break
if answer < target: print(" Too low.")
if answer > target: print(" Too high.")
print("\n THX.")