一个学校,有3个办公室,现在有8位老师等待工位的分配,请编写程序,完成随机的分配
import random
offices=[[],[],[]]
teachers=['1','2','3','4','5','6','7','8']
for teacher in teachers:
index=random.randint(0,2)
offices[index].append(teacher)
i=1
for office in offices:
num=len(office)
print('第%d个办公室有%d位老师'%(i,num))
print(office)
i+=1