-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuessingGameOne.py
More file actions
39 lines (30 loc) · 825 Bytes
/
GuessingGameOne.py
File metadata and controls
39 lines (30 loc) · 825 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
33
34
35
36
37
38
import random
def nhapso():
so = str(input("Please input a number 1-9: "))
while (not so.isdecimal()):
so = str(input("Please input a number correctly 1-9: "))
so = int(so)
while (so < 1 or so > 9):
so = str(input("Please input a number correctly 1-9: "))
so = int(so)
return so
def taoso():
"This function generate random number"
goal = random.randint(1, 9)
return goal
def startgame():
a = taoso()
b = nhapso()
c = 1
while (a != b):
if a < b:
print("Input a lower number: ")
b = nhapso()
c += 1
continue
else:
print("Input a higher number: ")
b = nhapso()
c += 1
continue
print("You win!!!!!!!!, you have try %d time(s)" % c)