-
Notifications
You must be signed in to change notification settings - Fork 0
/
replits100DaysOfPython_day43_takingListsToANewDimension.py
74 lines (59 loc) · 2.33 KB
/
replits100DaysOfPython_day43_takingListsToANewDimension.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import random #randint()
import os #system()
# Create a 2D List for the bingo card
# blank_bingoCard = []
blank_bingoCard = [[None, None, None],
[None, "BINGO", None],
[None, None, None]]
# test_blank_bingoCard = [[10, 22, 31],
# [41, "BINGO", 73],
# [84, 88, 89]]
# populate the card with random nums between 0 and 90
def create_blank_bingoCard():
random_numbers_list = []
ran_num_list_index = 0
for index in range(9):
random_numbers_list.append(random.randint(1, 90))
random_numbers_list.sort()
for row_index in range(len(blank_bingoCard)):
for column_index in range(len(blank_bingoCard[row_index])):
if blank_bingoCard[row_index][column_index] == None:
blank_bingoCard[row_index][column_index] = random_numbers_list[ran_num_list_index]
ran_num_list_index += 1
def print_bingoCard():
for row_index in range(len(blank_bingoCard)):
for column_index in range(len(blank_bingoCard[row_index])):
if column_index == (len(blank_bingoCard[row_index]) - 1):
print(f"{blank_bingoCard[row_index][column_index]:^4}")
elif column_index == (len(blank_bingoCard[row_index]) // 2):
print(f"{blank_bingoCard[row_index][column_index]:^7}|", end="")
else:
print(f"{blank_bingoCard[row_index][column_index]:^4}|", end="")
if row_index != (len(blank_bingoCard) - 1):
print("-" * 20)
print()
def print_main_menu():
os.system("cls")
print("David's Nan's Bingo Card Generator\n")
# MAIN PROGRAM
print_main_menu()
play = input("Press Enter to Play >> ")
print()
if not play:
while True:
create_blank_bingoCard()
print_bingoCard()
choice = input("Would you like to generate another bingo card?: ").strip().lower()
print()
if choice[0] == "y":
blank_bingoCard = [[None, None, None],
[None, "BINGO", None],
[None, None, None]]
print_main_menu()
continue
else:
print("Thanks for playing!\n\nExiting the program...\n")
exit()
else:
print("Input Detected. Exiting the program...\n")
exit()