0
from itertools import combinations

print(combinations(range(4), 2))

When I run: $ python testing.py

I get this instead of the combination outputs.

<itertools.combinations object at 0x7fb981c08d10>

How do I get the actual output?

icelov
  • 1
  • 2

1 Answers1

0

try (wrap combinations with list). Explanation: What you get is an iterator - wrapping it with list return the data struct you are looking for. See here for more.

from itertools import combinations

print(list(combinations(range(4), 2)))

output

[(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]
balderman
  • 22,927
  • 7
  • 34
  • 52