例题4,8个教师随机入住3个房间
import random
offices = [[], [], []]
names = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
for name in names:
index = random.randint(0, 2)
offices[index].append(name)
for i, office in enumerate(offices):
print('办公室%d有%d人。' % (i, len(office)))
for name in office:
print(name, end='\t')
print('\n')
print(('-'*30))