finding combinations in python code example

Example 1: python get all combinations of list

itertools.combinations(iterable, r)

Example 2: how to get all possible combinations in python

all_combinations = [list(zip(each_permutation, list2)) for each_permutation in itertools.permutations(list1, len(list2))]

Example 3: python combinations function

def combinations(iterable, r):
    pool = tuple(iterable)
    n = len(pool)
    for indices in permutations(range(n), r):
        if sorted(indices) == list(indices):
            yield tuple(pool[i] for i in indices)

Example 4: how to find combinations in ppython with a variable

how to find python combinations with variable