Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python all possible combinations of multiple lists

>>> import itertools
>>> a = [[1,2,3],[4,5,6],[7,8,9,10]]
>>> list(itertools.product(*a))
[(1, 4, 7), (1, 4, 8), (1, 4, 9), (1, 4, 10), (1, 5, 7), (1, 5, 8), (1, 5, 9), (1, 5, 10), (1, 6, 7), (1, 6, 8), (1, 6, 9), (1, 6, 10), (2, 4, 7), (2, 4, 8), (2, 4, 9), (2, 4, 10), (2, 5, 7), (2, 5, 8), (2, 5, 9), (2, 5, 10), (2, 6, 7), (2, 6, 8), (2, 6, 9), (2, 6, 10), (3, 4, 7), (3, 4, 8), (3, 4, 9), (3, 4, 10), (3, 5, 7), (3, 5, 8), (3, 5, 9), (3, 5, 10), (3, 6, 7), (3, 6, 8), (3, 6, 9), (3, 6, 10)]
Comment

get all combinations from two lists python

a = ["foo", "melon"]
b = [True, False]
c = list(itertools.product(a, b))
>> [("foo", True), ("foo", False), ("melon", True), ("melon", False)]
Comment

python get all combinations of list

itertools.combinations(iterable, r)
Comment

PREVIOUS NEXT
Code Example
Python :: python current time 
Python :: pandas percent change 
Python :: pandas - from umeric to string 
Python :: matplotlib y axis log scale 
Python :: display cv2 image in jupyter notebook 
Python :: normalize image in cv2 
Python :: python choose random element from list 
Python :: how copy and create same conda environment 
Python :: discord py bot status 
Python :: permanent redirect django 
Python :: python shebang line 
Python :: numpy compare arrays 
Python :: perfect number in python 
Python :: time decorator python 
Python :: normalize values between 0 and 1 python 
Python :: python check if a variable is an pandaDataframe 
Python :: cv2.imshow 
Python :: string to datetime 
Python :: change directory in python os 
Python :: return maximum of three values in python 
Python :: with font type stuff python turtle 
Python :: torch save state dict 
Python :: how to receive password using tkinter entry 
Python :: pandas astype string 
Python :: how to save a dictionary to excel in python 
Python :: grid in pygame 
Python :: How to Add a Title to Seaborn Plots 
Python :: python divide string in half 
Python :: importying listviewin django 
Python :: tkinter max size 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =