天天看點

八個老師随機配置設定三個辦公室                                                                   -------  知識無價,汗水有情,如需搬運請注明出處,謝謝!

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')
      

  

                                                                   -------  知識無價,汗水有情,如需搬運請注明出處,謝謝!

繼續閱讀