This error occurs when we try to call a non-callable object. The itertools.permutations()
function returns an iterator object containing all permutations of given iterable in a tuple form.
Here's an example code that will raise the TypeError: 'itertools.permutations' object is not callable
error:
main.py126 chars7 lines
To avoid this error, we need to iterate over the permutations object using a loop or convert it into a list and then we can access individual permutations by their indices.
Here's the correct code:
main.py199 chars12 lines
This will print all permutations of ['a','b','c'] using a loop. Alternatively, we can convert the permutation object to a list and then access the permutations using their indices.
gistlibby LogSnag