How can you iterate through dict items at the same time with variable dict length?
I want to iterate through a dict that has n keys and values.
eg:
d = {0:&quot;batched data&quot;, 1:&quot;batched data&quot;, 2:&quot;batched data&quot;, ..., n: &quot;batched data&quot;}

Since the batched data is of the pytorch DataLoader form, it is not indexable only iterable.
Thus, how can I iterate through all of the dict batched data at once:
I was thinking zip may be useful, but I was unsure how to compute this when the length is variable.
For instance if n=3:
for index, data in enumerate(zip(d[0],d[1],d[2])):

would work, but how can this be generalized for any number of dict elements?

Looking at the output of your command:
for index, data in enumerate(zip(d[0],d[1],d[2])):
    print(&quot;{} -&gt; {}&quot;.format(index, data))

it seems to me that this will handle the generic case:
d = {0:&quot;batched data&quot;, 1:&quot;batched data&quot;, 2:&quot;batched data&quot;, 3: &quot;batched data&quot;}

for index, data in enumerate(zip(*d.values())):
    print(&quot;{} -&gt; {}&quot;.format(index, data))

Output:
0 -&gt; ('b', 'b', 'b', 'b')
1 -&gt; ('a', 'a', 'a', 'a')
2 -&gt; ('t', 't', 't', 't')
3 -&gt; ('c', 'c', 'c', 'c')
4 -&gt; ('h', 'h', 'h', 'h')
5 -&gt; ('e', 'e', 'e', 'e')
6 -&gt; ('d', 'd', 'd', 'd')
7 -&gt; (' ', ' ', ' ', ' ')
8 -&gt; ('d', 'd', 'd', 'd')
9 -&gt; ('a', 'a', 'a', 'a')
10 -&gt; ('t', 't', 't', 't')
11 -&gt; ('a', 'a', 'a', 'a')

