# -*- coding:utf-8 -*-
import random
rooms = [[],[],[]]
teachers = ["A","B","C","D","E","F","G","H"]
for name in teachers:
randomNum = random.randint(0,2)
rooms[randomNum].append(name)
i = 1
for room in rooms:
print("辦公室%d老師的名字是:"%i)
for name in room:
#這里在print后面加一個逗號,可以不換行顯示
print(name),
print("")
i += 1
這里實現的是一個很簡單的功能,遍歷各個辦公室老師的名稱,很不可思議!
借鑒博客:
http://blog.csdn.net/leos_blog/article/details/17529621
