赞
踩
#题目:将八个老师随机分配到三个办公室中 import random offices = [[],[],[]] names = ["A","B","C","D","E","F","G","H"] for name in names: n = random.randint(0,2) offices[n].append(name) print(offices) #可以查看随机分派的办公室 i = 1 for office in offices: print("办公室%d的老师有%d人,分别为:"%(i,len(office))) i += 1 for name in office: print(name,end="\t") print(end="\n") print("-"*30)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。