-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBingo_game.py
51 lines (41 loc) · 907 Bytes
/
Bingo_game.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
import random, os, time
bingo = []
def ran():
number = random.randint(1,90)
return number
def prettyPrint():
for row in bingo:
for item in row:
print(item, end="\t|\t")
print()
def createCard():
global bingo
numbers = []
for i in range(8):
num = ran()
while num in numbers:
num = ran()
numbers.append(ran())
numbers.sort()
bingo = [ [ numbers[0], numbers[1], numbers[2]],
[ numbers[3], "BG", numbers[4] ],
[ numbers [5], numbers[6], numbers[7]]
]
createCard()
while True:
prettyPrint()
num = int(input("Next Number: "))
for row in range(3):
for item in range(3):
if bingo[row][item] == num:
bingo[row][item] = "X"
exes = 0
for row in bingo:
for item in row:
if item=="X":
exes+=1
if exes == 8:
print("You have won")
break
time.sleep(1)
os.system("clear")