Hello everybody.
I've a doubt about the for loop with two elements like this:
If I insert only one element I can iterate on the iterable (tuple) and print the sequence of integers:
However I cannot understand the firt case.
Thanks a lot.
I've a doubt about the for loop with two elements like this:
d1 = (1,2) d2 = (3,4) for item in (d1, d2): print(item)#Output
Output:(1, 2)
(3, 4)
Why I'm not iterating on all elements of d1 and after on d2 but receive the tuple and not single integers?If I insert only one element I can iterate on the iterable (tuple) and print the sequence of integers:
for item in (d1): print(item)#Output
Output:1
2
If I use the zip with both of them, I iterate at the same time of both and print two new tuples:for item in zip(d1, d2): print(item)#Output
Output:(1, 3)
(2, 4)
It's clear for me at this point.However I cannot understand the firt case.
Thanks a lot.