the itertools and collections modules the itertools and collections modules contain functions that can greatly simplify some common programming tasks we will start with some functions in itertools permutations and combinations permutations the permutations of sequence are rearrangements of the items of that sequence for examplesome permutations of [ , , are [ , , and [ , , here is an example that shows all the possibilitieslist(permutations([ , , ])[( , , )( , , )( , , )( , , )( , , )( , , )we can find the permutations of any iterable here are the permutations of the string ' ''join(pfor in permutations' ')[' '' '' '' '' '' 'the permutations function takes an optional argument that allows us to specify the size of the permutations for instanceif we just want all the two-element substrings possible from ' 'we can do the following'join(pfor in permutations' ' )[' '' '' '' '' '' 'note that permutations and most of the other functions in the itertools module return an iterator you can loop over the items in an iterator and you can use list to convert it to list