itertools.combinations: A better way to iterate through a pair of values in a Python list

itertools.combinations: A better way to iterate through a pair of values in a Python list

If you want to iterate through a pair of values in a list and the order does not matter ((a,b) is the same as (b, a)),  use itertools.combinations instead of two for loops.

Below is an example of using for loop compared to using itertools.combinations

Search

Related Posts

Scroll to Top

Work with Khuyen Tran

Work with Khuyen Tran