import itertools
list1 =list(range(5,10))
list2 =[1,2,3]list=[list1, list2]
combination =[p for p in itertools.product(*list)]print(combination)
PythonCopy
defcombinations(iterable, r):
pool =tuple(iterable)
n =len(pool)for indices in permutations(range(n), r):ifsorted(indices)==list(indices):yieldtuple(pool[i]for i in indices)
from itertools import permutations
from itertools import combinations
p = permutations([1,2,4])# or permutations([1, 2, 3], 2)for i in p:print(i)
c = combinations([1,2,3],2)for j in c:print(j)