Skip to content

Instantly share code, notes, and snippets.

@vlad-bezden
Created February 15, 2022 10:21
Show Gist options
  • Save vlad-bezden/6d4f606c8e4e83a6b0dfe07009232289 to your computer and use it in GitHub Desktop.
Save vlad-bezden/6d4f606c8e4e83a6b0dfe07009232289 to your computer and use it in GitHub Desktop.
Custom Python Zip Implementation
def emulated_zip(*iterables):
lists = [list(iterable) for iterable in iterables]
while all(lists):
yield tuple(current_list.pop(0) for current_list in lists)
numbers = emulated_zip(["one", "two"], [1, 2])
for i in numbers:
print(i)
# Output:
# ('one', 1)
# ('two', 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment