I'm trying to display all possible permutations of a list of numbers, for example if I have 334 I want to get:
3 3 4 3 4 3 4 3 3
I need to be able to do this for any set of digits up to about 12 digits long.
I'm sure its probably fairly simple using something like itertools.combinations but I can't quite get the syntax right.
TIA Sam
>>> lst = [3, 3, 4] >>> import itertools >>> set(itertools.permutations(lst)) {(3, 4, 3), (3, 3, 4), (4, 3, 3)}
2.1m questions
2.1m answers
60 comments
57.0k users