{"id":80204,"date":"2021-02-22T09:00:34","date_gmt":"2021-02-22T03:30:34","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=80204"},"modified":"2021-02-22T09:00:34","modified_gmt":"2021-02-22T03:30:34","slug":"itertools-module-in-python-with-examples","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/","title":{"rendered":"Itertools Module in Python with Examples"},"content":{"rendered":"<p>Itertool is one of the most amazing Python standard libraries. This specific library has pretty cool functions also, Python hence provides excellent documentation of the itertools.<\/p>\n<p>In this article, we\u2019ll read how and where it can be used.<\/p>\n<h3>Python \u2013 Itertools()<\/h3>\n<p>As in Mathematics, the Cartesian Product of two sets is defined as the set of all ordered pairs (p, q) where p belongs to P and q belongs to Q. Itertools are used in the calculations of such numeric codes.<\/p>\n<p>The itertools are also used in the various small operations of the codes which can easily be interpreted by the coder.<\/p>\n<p>While in some cases, a user may enter a numeral and may not directly convert it in binary, in such cases itertools also act as an interface between the codes.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">arr1 = [1, 2]\narr2 = [5, 6]\n\nprint((arr1, arr2)) \n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">([1, 2], [5, 6])<\/div>\n<h3>What are Itertools in Python?<\/h3>\n<p>Python Itertools is a library in Python generally consisting of multiple methods. These are used in various iterators to compute a fast and code efficient solution in the runtime.<\/p>\n<p>Itertools.product() falls under the category called Combinatorial iterators of the Python itertools library for user-defined functions.<\/p>\n<h3>What does itertools.product() do?<\/h3>\n<p>It is used to find the set or the product of any two binary numbers entered by the user. The itertools.product() can be used in two different ways as follow:<\/p>\n<p><strong>itertools.product(*iterables, repeat=1)<\/strong><\/p>\n<p>It returns the product of the entered numeric values as one. This can easily be interpreted by the coder.<\/p>\n<p><strong>itertools.product(*iterables)<\/strong><\/p>\n<p>It returns the cartesian product of all the numeric values without any manipulation in the code.<\/p>\n<p><strong>Python Itertools Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from itertools import product \n  # this imports the function\ndef thisistech(enter1, enter2): \n  #this allows the two data variables\n     return list(product(enter1, enter2))  \n    \nif __name__ == \"__main__\":  \n    enter1 = [56] \n    enter2 = [89] \n    print(thisistech(enter1, enter2)) \n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">[(56, 89)]<br \/>\n&gt;&gt;&gt;<\/div>\n<h4>Python Itertools.chain(*iterables)<\/h4>\n<p>This makes the iterable position of the variables as binary digits which can be easily identified by the coder.<\/p>\n<p>Technically, they are used for treating consecutive sequences as a single sequence. Its syntax is as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def c(*iterables):\n        for t in iterables:\n        for element in t:\n            yield element\nclassmethod c.from_iterable(iterable)\n<\/pre>\n<p><strong>Alternate constructor for chain()<\/strong><\/p>\n<p>A constructor chain is a default execution code in a loop using for while statements. This also helps the chain to create a multiple access code in one time.<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def from_iterable(iterables):\n      for t in iterables:\n        for element in t:\n            yield element\n<\/pre>\n<p>&nbsp;<\/p>\n<h4>itertools.combinations(iterable, r)<\/h4>\n<p>This gives the iterable element of the same list in the source code.<\/p>\n<p><strong>Syntax<\/strong><br \/>\ndef combinations(iterable, r):<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">p = tuple(iterable)\n    n = len(p)\n#this inputs all the values from n to n-1\n    if r &gt; n:\n        return\n    indices = range(r)\n#this changes the range of the values\n    yield tuple(pl[i] for i in indices)\n    while True:\n#a condition for reversed order is a must\n        for i in reversed(range(r)):\n            if indices[i] != i + n - r:\n                break\n        else:\n            Return\n#it count the indices number\n        indices[i] += 1\n        for j in range(i+1, r):\n            indices[j] = indices[j-1] + 1\n        yield tuple(pl[i] for i in indices)\n<\/pre>\n<h4>itertools.combinations_with_replacement(iterable, r)<\/h4>\n<p>The combinatorial and permutable based calculations are generally based on this code. This also helps the user in combining multiple lists in one time also.<\/p>\n<p><strong>Syntax<\/strong><br \/>\ndef combinations_with_replacement(iterable, r):<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">    p = tuple(iterable)\n    n = len(p)\n    if not n and r:\n        return\n    indices = [0] * r\n    yield tuple(p[i] for i in indices)\n    while True:\n        for i in reversed(range(r)):\n            if indices[i] != n - 1:\n                break\n        else:\n            return\n        indices[k:] = [indices[k] + 1] * (n - i)\n        yield tuple(p[k] for i in indices)\n<\/pre>\n<h4>itertools.compress(data, selectors)<\/h4>\n<p>This evaluates the compressed code as data and selectors which further adds in the execution of the code.<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def compress(data, selectors):\n      return (d for data, s in izip(data, selectors) if s)\n<\/pre>\n<h4>islice(iterable,stop)<\/h4>\n<p>This slices the list in two parts and creates a new list simultaneously.<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">islice(iterable,start,stop [,step])\n<\/pre>\n<p><strong>Example of Python Itertools islice():<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from itertools import islice\nfor thisistech in islice([50,89,90],900):\n                print(thisistech)\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">50<br \/>\n89<br \/>\n90<br \/>\n&gt;&gt;&gt;<\/div>\n<h4>itertools.count(start=0, step=1)<\/h4>\n<p>This makes the code iterable with any functional value as entered by the user and this by default takes the starting value as 1 and the ending value of the loop as 0.<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def count(start=0, step=1).\n    n = start\n    while True:\n        yield n\n        n += step\n<\/pre>\n<h4>itertools.cycle(iterable)<\/h4>\n<p>This itertool creates a repetitive cycle of executing code in such a way, that it takes different values every time from the user.<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def c(iterable):\n    saved = []\n    for element in iterable:\n        yield element\n        saved.append(element)\n    while saved:\n        for element in saved:\n              yield element\n<\/pre>\n<h4>itertools.dropwhile(predicate, iterable)<\/h4>\n<p>This dropdown the value as null, and if it has any calculations to do, then it takes the default value as one only.<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def dropwhile(predicate, iterable):\n    iterable = iter(iterable)\n    for i in iterable:\n        if not predicate(x):\n            yield i\n            break\n    for i in iterable:\n        yield i\n<\/pre>\n<h4>itertools.groupby(iterable[, key])<\/h4>\n<p>This groups the same additive elements in one part of the list and the rest in the other part.<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">groups = []\nuniquekeys = []\ndata = sorted(data, key=keyfunc)\nfor i, g in groupby(data, keyfunc):\n    groups.append(list(g))     \n    uniquekeys.append(1)\n\ndef __init__(self, iterable, key=None):\n        if key is None:\n      \n              while self.key == self.tkey:\n            self.value = next(self.it)    \n            self.key = self.keyfunc(self.currvalue)\n        self.tgtkey = self.currkey\n<\/pre>\n<h4>itertools.ifilter(predicate, iterable)<\/h4>\n<p>This as the name suggests, it predicts the iterable tools in the run time for the same code.<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def ifilter(predicate, iterable):\n      if predicate is None:\n        predicate = bool\n    for i in iterable:\n        if predicate(i):\n            yield i\n<\/pre>\n<h4>itertools.ifilterfalse(predicate, iterable)<\/h4>\n<p>This returns the false value of the statements. The execution which goes correct is treated as a null value.<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def ifilterfalse(predicate, iterable):\n    if predicate is None:\n        predicate = bool\n    for i in iterable:\n        if not predicate(i):\n            yield i\n<\/pre>\n<h4>itertools.izip(*iterables)<\/h4>\n<p>This simply zips the code like any other file which can only be extracted by a unique pin. Like zip() except that it returns an iterator instead of a list in the runtime.<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def izip(*iterables):\n    iterators = map(iter, iterables)\n    while iterators:\n        yield tuple(map(next, iterators))\n\n<\/pre>\n<h4>itertools.permutations(iterable[, r])<\/h4>\n<p>This performs a permutable iteration in a list, and also allows the user to do the same for 3 different lists in the runtime.<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">indices = range(i)\n    cycles = range(i, i-r, -1)\n    yield tuple(pool[i] for i in indices[:r])\n    while i:\n        for k in reversed(range(r)):\n            cycles[k] -= 1\n            if cycles[k] == 0:\n                indices[k:] = indices[k+1:] + indices[k:k+1]\n                cycles[k] = i - k\n            else:\n                j = cycles[k]\n                indices[k], indices[-j] = indices[-j], indices[k]\n                yield tuple(pool[k] for i in indices[:r])\n                break\n        else:\n            return\n<\/pre>\n<h4>itertools.repeat(object[, times])<\/h4>\n<p>A repeat object when provided with the number of times, repeats the code in such a manner that it has different arguments every time.<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def repeat(object, times=N):\n    if times is N:\n        while True:\n            yield object\n    else:\n        for i in xrange(times):\n            yield object\n<\/pre>\n<p>A very general repeat system is followed in the code, which allows the recursive execution of the same code in multiple run time.<\/p>\n<h4>itertools.starmap(function, iterable)<\/h4>\n<p>The starmap attribute is different from others as it works on the unique key elements of the list only.<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def starmap(function, iterable)\n    for args in iterable:\n        yield function(*args)\n<\/pre>\n<h3>Python grouper Recipe<\/h3>\n<p>A grouper recipe handles only one code at a time. It does not allow the execution of twoTarguments simultaneously in a code.<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&gt;&gt;&gt; numbdef = []\n&gt;&gt;&gt; listfirst(better_grouper(nums, 2))\n<\/pre>\n<p><strong>Sequences of Numbers:<\/strong> This signifies the sequence and series of display of the list. It can be of any mathematical type, but the coder needs to keep in mind that the only accepted value of this list should be an integer.<\/p>\n<p><strong>Evens and Odds sequence:<\/strong> This displays the sequence of even and odd numbers in a series.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">thisistech=int(input(\"Number to check is : \"));\nif(thisistech%2==0):\n    #it will return a number by dividing it by two\n   print(\"Even\")\nelse:\n  print(\"Odd\")\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Number to check is : 6<br \/>\nEven<br \/>\n&gt;&gt;&gt;<\/div>\n<h3>Python Recurrence Relations<\/h3>\n<p>This as defined by name means recurring repetition of the key element in the main list. But it also signifies the calculated element is not replicated further. The best-known recurrence relation is the Fibonacci sequence.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def fibsnumb():\n    p,q = 0, 1\n    #define the fib\n    while True:\n        #this will check the entered number\n        yield p\n        p, q = p, q + p\n<\/pre>\n<p>#yield will act as a print statement<\/p>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">&gt;&gt;&gt; True<br \/>\nTrue<br \/>\n&gt;&gt;&gt;<\/div>\n<p><strong>1. First Order Recurrence Relations:<\/strong><\/p>\n<p>This means it repeats only the first element of any list, the other elements as left as it is only.<\/p>\n<p><strong>Syntax<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">count_by_one = it.count(step=1)<\/pre>\n<p><strong>2. Second-Order Recurrence Relations:<\/strong><\/p>\n<p>A second-order recurrence defines the unique list in a sorted way.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">fibs = second\n#this will show error\nli(next(fibs) for _ in range(6))\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">error<\/div>\n<p><strong>Intermission: Flattening A List of Lists<\/strong><\/p>\n<p>This helps the user flatten the list and check its all elements one by one. This is also helpful in merging two lists with different data types for any relational databases also.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">thisistech='1','2','3'\nfor li in range (1,8):\n    print(li)\n\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">1<br \/>\n2<br \/>\n3<br \/>\n4<br \/>\n5<br \/>\n6<br \/>\n7<br \/>\n&gt;&gt;&gt;<\/div>\n<h3>Python Maximum Gain and Loss<\/h3>\n<p>This displays the maxima and the minima of the data, or a graph logically by simply evaluating and comparing every element with the other element.<\/p>\n<p>To determine the maximum gain or loss as a programming function, the coder can do this:<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">a=[34,56,78]\np=max(a)\nprint(p)\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">78<br \/>\n&gt;&gt;&gt;<\/div>\n<p><strong>Using next() function:<\/strong> This attribute helps in moving from one element to the other in the same list.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import itertools  \nI = \"TechVidvan\"\n  \n#for i in range(I):\nprint(I)  \n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">TechVidvan<\/div>\n<h3>Cloning sequences with tee()<\/h3>\n<p>This is a case of copying one list\u2019s elements to the other list without the actual data change in final lists. In this case, the original sequence cannot be used more than once. Cloning is a special case of copying, it is done when the user decides to copy and save the previous data as it is in the new data table. Cloning does not allow the updation or ammendation of the data.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from itertools import *\n\nfor n in THISISTECH:\n    print('cloned: {}'.f(numbprint))\nfor B in THISISTECH:\n    print('cloned1: {}'.f(numbprint))\n\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">ERROR<\/div>\n<h3>Accumulating Operations with accumulate()<\/h3>\n<p>To accumulate a function in the code one needs to copy the identifiers from the library and then execute the same in the code. Like adding the numbers to the previous value in the sequence within the run time for user-defined codes.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from itertools import *\n\nTHISISTECH = accumulate(range(6))\nfor val in THISISTECH:\n    print(val)\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">0<br \/>\n1<br \/>\n3<br \/>\n6<br \/>\n10<br \/>\n15<\/div>\n<p><strong>filter items with takewhile():<\/strong> This method helps the coder in identifying the unique value in the lists. It is also useful in identifying the pin key of the code and hence inserting the same in the main list also. It helps the user sort the list according to his own priorities.<\/p>\n<p><strong>Syntax for Python takewhile()<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">itertools.takewhile(predicate, sequence)<\/pre>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from itertools import *\n\nTHISISTECH = takewhile(lambda i: i &lt;  [3, 12])\nfor val in THISISTECH:\n    print(val)\n\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">ERROR<\/div>\n<h2>Conclusion<\/h2>\n<p>In this article we\u2019ve read what are itertools, how are they user-oriented functions and how can they be used in a code. Towards the end of the article, we\u2019ve also read the various categories in which these tools can be efficiently used.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Itertool is one of the most amazing Python standard libraries. This specific library has pretty cool functions also, Python hence provides excellent documentation of the itertools. In this article, we\u2019ll read how and where&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":80229,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1053],"tags":[3363,3364,3365],"class_list":["post-80204","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-itertools-in-python","tag-python-itertools","tag-python-itertools-module"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Itertools Module in Python with Examples - TechVidvan<\/title>\n<meta name=\"description\" content=\"Python&#039;s Itertool is a module that provides various functions that work on iterators to produce complex iterators. Learn more about it.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Itertools Module in Python with Examples - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Python&#039;s Itertool is a module that provides various functions that work on iterators to produce complex iterators. Learn more about it.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-02-22T03:30:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/01\/python-itertools-module.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Itertools Module in Python with Examples - TechVidvan","description":"Python's Itertool is a module that provides various functions that work on iterators to produce complex iterators. Learn more about it.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/","og_locale":"en_US","og_type":"article","og_title":"Itertools Module in Python with Examples - TechVidvan","og_description":"Python's Itertool is a module that provides various functions that work on iterators to produce complex iterators. Learn more about it.","og_url":"https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-02-22T03:30:34+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/01\/python-itertools-module.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Itertools Module in Python with Examples","datePublished":"2021-02-22T03:30:34+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/"},"wordCount":1299,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/01\/python-itertools-module.jpg","keywords":["Itertools in python","Python Itertools","Python Itertools module"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/","url":"https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/","name":"Itertools Module in Python with Examples - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/01\/python-itertools-module.jpg","datePublished":"2021-02-22T03:30:34+00:00","description":"Python's Itertool is a module that provides various functions that work on iterators to produce complex iterators. Learn more about it.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/01\/python-itertools-module.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/01\/python-itertools-module.jpg","width":1200,"height":628,"caption":"Itertools module in Python"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/itertools-module-in-python-with-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Itertools Module in Python with Examples"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/80204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=80204"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/80204\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/80229"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=80204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=80204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=80204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}