I have these two lists
l1 = [1,2,3]
l2 = [10,20,30]
I use this nested for loop to access all possible pairs:
for a in l1:
for b in l2:
print(a,b)
I get the following expected result:
1 10
1 20
1 30
2 10
2 20
2 30
3 10
3 20
3 30
But if I convert l1 and l2 to iterators, I get a different result and I can't access to all of the pairs:
l1=iter(l1)
l2=iter(l2)
for a in l1:
for b in l2:
print(a,b)
1 10
1 20
1 30
I can't understand the difference between these two code snippets. Why the iterators generate this result?