员工随机分配
作者:互联网
import random
office = [[] for x in range(3)]
names = ['A','B','C','D','E','F','G','H','i','j','k']
for name in names:
randomClass = random.randint(0,2)
office[randomClass].append(name)
i = 1
for tempName in office:
print("属于办公室%d的人数有%d个"%(i,len(tempName)))
i+=1
for realName in tempName:
# print(realName)
print("%s" % realName, end='')
print('\n')
print('*'*20)
属于办公室1的人数有3个
ABG
********************
属于办公室2的人数有4个
CDik
********************
属于办公室3的人数有4个
EFHj
********************
标签:办公室,realName,office,员工,随机,print,人数,分配,tempName 来源: https://blog.csdn.net/yeler082/article/details/90340600