From 95664e881c834cf4c50049a2f4e37c0ac25f4e5f Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Sat, 30 Dec 2023 16:45:44 +0100 Subject: [PATCH] Update README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- python_basics/zip/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/python_basics/zip/README.md b/python_basics/zip/README.md index 02b056b..55fbfdf 100644 --- a/python_basics/zip/README.md +++ b/python_basics/zip/README.md @@ -34,3 +34,10 @@ Output: (2, 'spice') (3, 'everything nice') ``` + +> More formally: zip() returns an iterator of tuples, where the i-th tuple contains the i-th element from each of the argument iterables. + +> By default, zip() stops when the shortest iterable is exhausted. It will ignore the remaining items in the longer iterables, cutting off the result to the length of the shortest iterable + +> zip() is often used in cases where the iterables are assumed to be of equal length. In such cases, it’s recommended to use the strict=True option. Its output is the same as regular zip(). Unlike the default behavior, it raises a ValueError if one iterable is exhausted before the others. +