Itertools Hacks
Avoiding nested loops
Without Itertools
With Itertools
And of course the itertools example, if it is as simple as a single function call, can be shortened to :
Also it can be extended to multiple lists, iterables etc, without needing to have another nested loop.
Infinite loop with a count
Without Itertools
With Itertools
no risk of ever stepping past the increment line by doing a continue for instance (been there, done that)
Running lists together
Without Itertools
With Itertools
Itertools with list of list
List with Condition
Without Itertools
With Itertools
Last updated