python 小案例demo05

#7、随机数配合二维数组 做出一个 Offices里面随机出人名来
import random
offices = [[],[],[]]
names = ["A","B","C","D","E","F","G"]
for name in names:
index = random.randint(0,2)
offices[index].append(name)
i = 1
for office in offices:
print("办公室%d 人数为%d"%(i,len(office)))
i += 1
for name in office:
print("%s"%name,end="\t")
print("\n")
print("-"*30)
posted @ 2020-10-28 12:33  AxeBurner  阅读(72)  评论(0编辑  收藏  举报