说我正在迭代Python中的列表:
lines = [1, 2, 3, 4]
linecount = len(lines)
#I want to be able to do this:
for i, j in range(linecount - 1, -1, -1), range(linecount, -1, -1):
print i, j
"""
This would print out
3 4
2 3
1 2
0 1
0 0
"""
我怎么能这样做?
答案 0 :(得分:4)
for i, j in zip(range(linecount - 1, -1, -1), range(linecount, -1, -1)):
print i, j