【发布时间】:2019-09-26 05:18:22
【问题描述】:
我有一个列表和一个列表,看起来像这样
groups = ['1','2','3','4','5']
weeks = [['e','e','e','e','e','e','e'],
['o','o','m','m','m','o','o'],
['l','l','l','l','l','o','o'],
['m','m','m','m','m','o','o'],
['m', 'm','m','m','m','o','o']]
我可以使用此代码在几周内迭代 for 循环
for i in range(5):
for j in range(7):
roster = (weeks[i][j])
display(roster)
但我希望我的输出是,
e 1
e 1
e 1 ... #for the first row in the weeks list then
o 2
o 2
m 2 ... #for the next row of the and so on till it reaches the last row.
【问题讨论】:
标签: python-3.x for-loop iteration nested-lists