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

how to find a combination of all elements in a python list

import itertools

stuff = [1, 2, 3]
for L in range(0, len(stuff)+1):
    for subset in itertools.combinations(stuff, L):
        print(subset)
Comment

python get all combinations of list

itertools.combinations(iterable, r)
Comment

PREVIOUS NEXT
Code Example
Python :: python default input 
Python :: how to get the code of a website in python 
Python :: change each line color as a rainbow python 
Python :: filter list dict 
Python :: how to run commands in repl.ot 
Python :: Qslider pyqt 
Python :: how to run single loop iterations on same time in python 
Python :: rangoli in python 
Python :: how to change the datatype of a row in pandas 
Python :: dice roller python 
Python :: python reverse string 
Python :: feet to meter python 
Python :: python read png file 
Python :: Static Assets in Django 
Python :: python change format of datetime 
Python :: how to convert string to date object in python 
Python :: python check list contains another list 
Python :: python- number of row in a dataframe 
Python :: python create folder if not exists 
Python :: frequency unique pandas 
Python :: django admin image 
Python :: grassmann formula 
Python :: tqdm parallel 
Python :: encrypt and decrypt python 
Python :: convert two numpy array to pandas dataframe 
Python :: remove n string 
Python :: how to convert input to uppercase in python 
Python :: activate venv enviroment 
Python :: python find location of module 
Python :: narcissistic number python 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =