爬虫 复习python基础知识(老师分教室)

import random
classroom = [[],[],[]]
teachers = ["A","B","C","D","E","F","G","H"]
for teacher in teachers:
    classroom[random.randint(0,2)].append(teacher)
for i in range(3):
    print("第%d个教室有%d个人"%(i+1,len(classroom[i])))
    for j in range(len(classroom[i])):
        print(classroom[i][j],end="\t")
    print("\n")
    print("*"*20)

结果
爬虫 复习python基础知识(老师分教室)_第1张图片

你可能感兴趣的:(爬虫,练习,python,列表)