欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

列表联系(回炉练习)

程序员文章站 2023-01-12 13:20:58
__author__ = 'zht' #!/usr/bin/env python # -*- coding: utf-8 -*- ''' #努力学习每一天 ''' import random offices = [[],[],[]] names = ['A','B','C','D','E','F',... ......
__author__ = 'zht'
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
#努力学习每一天
'''

import  random

offices = [[],[],[]]

names = ['A','B','C','D','E','F','G','H']

i = 1

for name in names:
    index = random.randint(0,2)
    offices[index].append(name)
print(offices)

for temp in offices:
    print("办公室%d的人数为%d"%(i,len(temp)))

    for name in temp:
        print("%s"%(name),end=',')
    i+= 1
    print("\n")

  

#某个学校,有3个办公室,现在有8位老师等待工位的分配,请编写程序,完成随机的分配