...

/

Lossy Zip of Iterators

Lossy Zip of Iterators

We'll cover the following...

Zipping up lists will keep them all safe in one place, right? Let’s find out!

Press + to interact
numbers = list(range(7))
print(numbers)
first_three, remaining = numbers[:3], numbers[3:]
print(first_three, remaining)
numbers_iter = iter(numbers)
print(list(zip(numbers_iter, first_three)))
# so far so good, let's zip the remaining
print(list(zip(numbers_iter, remaining)))

Where did element 3 go from the numbers list?

Explanation

...