From 9fc6be8724a690c3d272a155d4eaaa4d743c8ae0 Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Sat, 30 Dec 2023 16:43:08 +0100 Subject: [PATCH] Create README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- python_basics/zip/README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 python_basics/zip/README.md diff --git a/python_basics/zip/README.md b/python_basics/zip/README.md new file mode 100644 index 0000000..02b056b --- /dev/null +++ b/python_basics/zip/README.md @@ -0,0 +1,36 @@ +# zip +{:.no_toc} + + + +## Top + +Questions to [David Rotermund](mailto:davrot@uni-bremen.de) + +## [zip](https://docs.python.org/3/library/functions.html#zip) + + +```python +zip(*iterables, strict=False) +``` + +> Iterate over several iterables in parallel, producing tuples with an item from each one. + +```python +a = zip([1, 2, 3], ["sugar", "spice", "everything nice"]) +print(a) # -> + +for item in zip([1, 2, 3], ["sugar", "spice", "everything nice"]): + print(item) +``` + +Output: + +```python +(1, 'sugar') +(2, 'spice') +(3, 'everything nice') +```