import itertools
print(list(itertools.permutations([1,2,3])))
import itertools
a = [1, 2, 3]
n = 3
perm_iterator = itertools.permutations(a, n)
for item in perm_iterator:
print(item)
from itertools import permutations
a=permutations([1,2,3,4],2)
for i in a:
print(i)
from itertools import permutations
string="SOFT"
a=permutations(string)
for i in list(a):
# join all the letters of the list to make a string
print("".join(i))
import itertools
list(itertools.permutations([1, 2, 3]))
>>> from itertools import permutations
>>> perms = [''.join(p) for p in permutations('stack')]
>>> perms
# Function to find permutations of a given string
from itertools import permutations
def allPermutations(str):
# Get all permutations of string 'ABC'
permList = permutations(str)
# print all permutations
for perm in list(permList):
print (''.join(perm))
# Driver program
if __name__ == "__main__":
str = 'ABC'
allPermutations(str)
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)