pytutorial/python_basics/zip
David Rotermund 9fc6be8724
Create README.md
Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com>
2023-12-30 16:43:08 +01:00
..
README.md Create README.md 2023-12-30 16:43:08 +01:00

zip

{:.no_toc}

* TOC {:toc}

Top

Questions to David Rotermund

zip

zip(*iterables, strict=False)

Iterate over several iterables in parallel, producing tuples with an item from each one.

a = zip([1, 2, 3], ["sugar", "spice", "everything nice"])
print(a)  # -> <zip object at 0x7f34987f4380>

for item in zip([1, 2, 3], ["sugar", "spice", "everything nice"]):
    print(item)

Output:

(1, 'sugar')
(2, 'spice')
(3, 'everything nice')