Answers for "all possible combinations of array elements python"

6

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)]
Posted by: Guest on April-21-2020
0

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)
Posted by: Guest on April-05-2021

Code answers related to "all possible combinations of array elements python"

Python Answers by Framework

Browse Popular Code Answers by Language