我该如何在同一个 for
循环中包含两个变量?
t1 = [a list of integers, strings and lists]
t2 = [another list of integers, strings and lists]
def f(t): #a function that will read lists "t1" and "t2" and return all elements that are identical
for i in range(len(t1)) and for j in range(len(t2)):
...
x
和y
均为3,则同时(也称为“锁步”或“并行”)迭代将给出0, 0
,然后是1, 1
,最后是2, 2
; 嵌套迭代将依次得到0, 0
,0, 1
,0, 2
,1, 0
,1, 1
,1, 2
,2, 0
,2, 1
,2, 2
。(或者您是否需要与这两种方法都不同的结果?如果是,请说明您需要什么。) - abarnert