天天看点

八个老师随机分配三个办公室                                                                   -------  知识无价,汗水有情,如需搬运请注明出处,谢谢!

import random
office = [[], [], []]
teacher = ['t1', 't2', 't3', 't4', 't5', 't6', 't7', 't8']
for t in teacher:
    of = random.randint(0, 2)
    office[of].append(t)
print(office)
i = 0
for x in office:
    i += 1
    print('第%d个办公室有%d个人,是:' % (i, len(x)), end='')
    for n in x:
        print(n, end='\t')
    print('\n')
      

  

                                                                   -------  知识无价,汗水有情,如需搬运请注明出处,谢谢!

继续阅读