import random
#定义一个列表用来保存3个办公室
offices ==[[],[],[]]
#定义一个列表用来储存8位老师的名字
names =[‘A’,‘B’,‘C’,‘D’,‘E’,‘F’,‘G’,‘H’]
i=0
for name in names;
index = random.randint(0,2)
offices[index].append(name)
i =1
for tempName in offices;
print(‘办公室%d的人数为:%d’%(i,len(tempNames)))
i+=1
for name in tempNames:
print("%s"%name,end=’’)
print("\n")
print("-"20)
列表的嵌套(列表list)
最新推荐文章于 2024-04-30 10:57:38 发布