Python permutations generator

permutations(n,r) generator returns the permutation of n by r.

>>> from itertools import *
>>> data = [2,6,9,3]
>>> x = permutations(data,2)
>>> for i in x:
>>> print (i)
(2, 6)
(2, 9)
(2, 3)
(6, 2)
(6, 9)
(6, 3)
(9, 2)
(9, 6)
(9, 3)
(3, 2)
(3, 6)
(3, 9)




















endmemo.com © 2024  | Terms of Use | Privacy | Home