# 1.3个办公室(办公室:列表) 列表嵌套
classroomList = [[], [], []]
# 2.8位老师 列表中保存
teachers = ['袁腾飞', '罗永浩', '俞敏洪', '李永乐', '王芳芳', '马云', '李彦宏', '马化腾']
# 3.每一个办公室中添加一名老师,遍历办公室还是老师列表 办公室:1 老师 2
for classroom in classroomList:
# 随机获取一名老师
# teacher = teachers[random.randint(0,len(teachers)-1)]
# 添加到办公室中
classroom.append(teachers.pop(random.randint(0,len(teachers)-1)))
# 从老师列表中删除这个元素
# del teachers[index]
# teachers.remove(teacher)
# print(classroomList)
# print(teachers)
# 4.把剩下的老师随机分配到办公室中
for teacher in teachers:
# 随机办公室的角标 Ctrl+P查看提示
# Ctrl+Alt+V 提取变量
index = random.randint(0, 2)
# 4.随机存放到办公室中
classroom = classroomList[index]
classroom.append(teacher)
# 清空teachers
teachers.clear()
print(classroomList)
print(teachers)