pairwise function python

Solutions on MaxInterview for pairwise function python by the best coders in the world

showing results for - "pairwise function python"
Christopher
05 May 2016
1# itertools — Functions creating iterators for efficient looping
2# See : https://docs.python.org/3/library/itertools.html
3import itertools
4x = [A,1,B,2]
5l = list(itertools.combinations(x, 2))
6print(l)
7[(A, 1), (A, B), (A, 2), (1, B), (1, 2), (B, 2)]
8