I'm trying to iterate over 3 elements at a time using the following (which seems to work):
for a, b, c in zip(*[iter(accounts_iter)]*3):
print(a)
print(b)
print(c)
accounts_iteris a list of tuples I created.iter(accounts_iter)unpacksaccounts_iterinto a list iterator, so its still a list of tuples just that its now iterable
Here's where I struggle to understand.
*[iter(accounts_iter)]unpacks the list inStep 2into separate tuples, so no longer a list of tuples but individual tuples*[iter(accounts_iter)]*3multiplies that by 3
In my output, I do not seem to have duplicates, but am indeed able to process 3 items each loop.
But won't I have 3 copies of the same tuple once zip(*[iter(accounts_iter)]*3) happens?