1

I would like to to get list of all pairs of numbers between 0 and 100:

[(0,0), (0,1), (0,2),...,(99,99)]

How can I make it in pythonic way? Cause I know, that I can just append needed tuples in two for cycles.

Thank you in advance.

Acapello
  • 117
  • 8

1 Answers1

1

What you want is itertools.product(*iterables).

import itertools
list(itertools.product((range(100), range(100)))
CrazyCasta
  • 24,620
  • 4
  • 41
  • 67
  • No problem, itertools has a lot of fun stuff. Does about 95% of what you would ever need in terms of "manipulating" iterators. – CrazyCasta Mar 06 '16 at 09:07