1# A Python program to print all permutations using library function
2from itertools import permutations
3perm = permutations([1, 2, 3])
4for i in list(perm):
5 print (i)
6# (1, 2, 3)
7# (1, 3, 2)
8# (2, 1, 3)
9# (2, 3, 1)
10# (3, 1, 2)
11# (3, 2, 1)
1import itertools
2
3a = [1, 2, 3]
4n = 3
5
6perm_iterator = itertools.permutations(a, n)
7
8for item in perm_iterator:
9 print(item)
1>>> from itertools import permutations
2>>> perms = [''.join(p) for p in permutations('stack')]
3>>> perms
4
1T=[i for i in range(8)]
2for i in range(8):
3 print("T[",i,"]= ",end="")
4 T[i]=int(input())
5print("Tableau avant permutation")
6print(T)
7k=7
8for i in range(4):
9 X=T[i]
10 T[i]=T[k]
11 T[k]=X
12 k=k-1
13print("Tableau après permutation")
14print(T)