列表联系(回炉练习)
程序员文章站
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位老师等待工位的分配,请编写程序,完成随机的分配
上一篇: 编程实现对一个元素全为数字的列表,求最大值、最小值(回炉笔记)
下一篇: 倚天屠牛记