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=" ")
print(" ")
print("-"*30)
原文地址:https://www.cnblogs.com/bichen-01/p/13890339.html