itertools.permutation
function is used to compute permutations of iterable. The following is the syntax to import permutations module from itertools:
main.py35 chars2 lines
Once imported, you can use it to compute permutations as follows:
main.py63 chars4 lines
Output:
main.py67 chars2 lines
Here, permutations(lst)
computes all the possible permutations of the elements in a list lst
. Hope this helps!
gistlibby LogSnag