From c0c3c4c624caa5bf339707baee143aba0617b32c Mon Sep 17 00:00:00 2001 From: girraj jangid <34280160+Girrajjangid@users.noreply.github.com> Date: Fri, 7 Dec 2018 14:34:54 +0530 Subject: [PATCH] Add 'changes' to this article (#25019) * Add 'changes' to this article * add changes to this file --- guide/english/python/itertools/index.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/guide/english/python/itertools/index.md b/guide/english/python/itertools/index.md index 48fe691059..39887e8df0 100644 --- a/guide/english/python/itertools/index.md +++ b/guide/english/python/itertools/index.md @@ -42,6 +42,17 @@ list(izip([1, 2, 3], ['a', 'b', 'c'])) # Output # [(1, 'a'),(2, 'b'),(3, 'c')] ``` +### compress() + +It make an iterator that filters elements from data returning only those that have a corresponding element in selectors that evaluates to True. Stops when either the data or selectors iterables has been exhausted. + +```py +import itertools +itertools.compress('ABCDEF', [1,0,1,0,1,1]) + +# Output +# A C E F +``` ### Combinatoric iterators @@ -69,5 +80,7 @@ list(product(*B)) # [(1, 3, 7), (1, 3, 8), (1, 4, 7), (1, 4, 8), (1, 5, 7), (1, 5, 8), (2, 3, 7), (2, 3, 8), (2, 4, 7), (2, 4, 8), (2, 5, 7), (2, 5, 8), (3, 3, 7), (3, 3, 8), (3, 4, 7), (3, 4, 8), (3, 5, 7), (3, 5, 8)] ``` -Source: https://docs.python.org/3/library/itertools.html -https://www.hackerrank.com/challenges/itertools-product/problem +#### More Information +- [Python Itertools Docs](https://docs.python.org/3/library/itertools.html) +- [Hackerrank](https://www.hackerrank.com/challenges/itertools-product/problem) +