Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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)]
Comment

PREVIOUS NEXT
Code Example
Python :: python series to list of string 
Python :: pygame zero how to draw text 
Python :: python3 ngrok.py 
Python :: split string in python 
Python :: python remove space from end of string 
Python :: numpy delete column 
Python :: show columns pandas 
Python :: check python version 
Python :: pandas groupby mean 
Python :: python cv2 convert image to binary 
Python :: Find Specific value in Column 
Python :: pandas sort dataframe by column 
Python :: how do i turn a tensor into a numpy array 
Python :: python convert multidimensional array to one dimensional 
Python :: count unique elements in list python 
Python :: python pygame how to start a game 
Python :: python extract zip file without directory structure 
Python :: python cast list to float 
Python :: find the difference in python 
Python :: python lists as dataframe rows 
Python :: get the current date and time in python 
Python :: set type of column pandas 
Python :: how to define function in python 
Python :: try python import 
Python :: open word from python 
Python :: django regexvalidator example 
Python :: generate dates between two dates python 
Python :: scikit learn pca 
Python :: python character list to string 
Python :: two dimensional array python 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =