Answers for "generate all combinations of list with repetition oython"

2

combination without repetition python

import itertools as it
list(it.combinations([1,2,3,4,5], 4))
#[(1, 2, 3, 4), (1, 2, 3, 5), (1, 2, 4, 5), (1, 3, 4, 5), (2, 3, 4, 5)]
Posted by: Guest on March-11-2020
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

Code answers related to "generate all combinations of list with repetition oython"

Python Answers by Framework

Browse Popular Code Answers by Language