Record#
- Today I learned about two-dimensional arrays. The first dimension of a two-dimensional array is a list, and the second dimension contains the information within the list.
- For example: my2dlist = [["张三",20],["李四",28]]. Print: print (my2dlist [0]) = [["张三",20]]. print (my2dlist [0][0]) = 张三
- Edit the array: my2dlist [0][0] = "王五", print (my2dlist [0][0]) = 王五
- Today's exercise was to print a bingo card. I spent half an hour on it and couldn't figure it out. The correct answer in the end doesn't match the instructions. Maybe I overcomplicated it.
CODE#
import random
bingo = []
def ran():
number = random.randint(1,90)
return number
def prettyPrint():
for row in bingo:
print(row)
numbers = []
for i in range(8):
numbers.append(ran())
numbers.sort()
bingo = [ [ numbers[0], numbers[1], numbers[2]],
[ numbers[3], "BINGO", numbers[4] ],
[ numbers [5], numbers[6], numbers[7]]
]
prettyPrint()