Python 随机分配老师到办公室

Python 随机分配老师到办公室,第1张

Python 随机分配老师办公室 3个办公室,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)
i = 1
for office in offices:
    print("办公室%d的人数为:%d" % (i, len(office)))
    i += 1
    for name in offices:
        print("%s" % name, end="t")
    print("n")
    print("-"*20)


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5579691.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-14
下一篇 2022-12-14

发表评论

登录后才能评论

评论列表(0条)

保存