2

Possible Duplicate:
How to generate all permutations of a list in Python

Say I have a range, 0-2. I want to shuffle these numbers and print out all of the possibilities:

[0, 1, 2]
[0, 2, 1]
[1, 2, 0]
[1, 0, 2]
[2, 0, 1]
[2, 1, 0]

How would I do this in Python for any range 0-N?

Community
  • 1
  • 1
Kobi
  • 1,395
  • 4
  • 17
  • 23
  • 5
    See [How to generate all permutations of a list in Python](http://stackoverflow.com/questions/104420/how-to-generate-all-permutations-of-a-list-in-python) and the `range` function. – hobbs May 03 '12 at 04:51

1 Answers1

1

itertools.permutations()

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358