0
Q:

python permutations of a list

from itertools import permutations
l = list(permutations(range(1, 4)))
print l
1
# A Python program to print all  
# permutations using library function 
from itertools import permutations 
  
# Get all permutations of [1, 2, 3] 
perm = permutations([1, 2, 3]) 
  
# Print the obtained permutations 
for i in list(perm): 
    print i 
3
>>> import itertools
>>> lnums = (list(itertools.permutations([0, 1], 2)))
>>> print(lnums[0])
(0, 1)
>>> print(lnums[1])
(1, 0)
2
from itertools import permutations 
l = list(permutations(range(1, 4))) 
print l 
0

New to Communities?

Join the community