permutation and combination in python code example
Example 1: all permutations python
import itertools
print(list(itertools.permutations([1,2,3])))
Example 2: combinations and permutations in python
from itertools import permutations
from itertools import combinations
Example 3: permutation and combination code in python
from itertools import combinations
comb = combinations([1, 2, 3], 2)
for i in list(comb):
print (i)
Example 4: permutation and combination code in python
from itertools import permutations
perm = permutations([1, 2, 3], 2)
for i in list(perm):
print (i)
Example 5: import permutations
from itertools import permutations