记录#
- 今天学习二维数组。二维数组的第一维是 list,第二维才是 list 内的信息。
- 如:my2dlist=[["张三",20],["李四",28]]。打印: print (my2dlist [0])=[["张三",20]。print (my2dlist [0][0])= 张三
- 编辑数组:my2dlist [0][0] = "王五",print (my2dlist [0][0])= 王五
- 今天的练习是打印 bing card ,写了半个小时没搞定,最后的正确答案按题目讲也不对。可能是我想太复杂了。
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()