Created
February 15, 2022 10:21
-
-
Save vlad-bezden/6d4f606c8e4e83a6b0dfe07009232289 to your computer and use it in GitHub Desktop.
Custom Python Zip Implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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