Answers for "select all pairs of possible numbers from array python"

0

python get unique pairs from two lists

# note: this works for two list only
from itertools import product

l1 = [1,2,3]
l2 = [4,5,6] # works if the second list has a different lenght too

product(l1, l2)
>>> <itertools.product object at 0x7f1539c89af0>

list(product(l1, l2))
>>> [(1, 4), (1, 5), (1, 6), 
     (2, 4), (2, 5), (2, 6), 
     (3, 4), (3, 5), (3, 6)]
Posted by: Guest on September-09-2021
0

python all possible pairs

list(itertools.combinations(iterable, r))
Return r length subsequences of elements from the input iterable.

Combinations are emitted in lexicographic sort order. 
So, if the input iterable is sorted, 
the combination tuples will be produced in sorted orde
Posted by: Guest on June-06-2021

Code answers related to "select all pairs of possible numbers from array python"

Python Answers by Framework

Browse Popular Code Answers by Language