Question: I have a list of numbers: [0, 0, 1, 1, 2, 2]

I want to have all combinations of 2 numbers, I tried to do it with itertools:

```
import itertools
a = [0, 0, 1, 1, 2, 2]
combinations = set(itertools.permutations(a, 2))
print(combinations)
# {(0, 1), (1, 2), (0, 0), (2, 1), (2, 0), (1, 1), (2, 2), (1, 0), (0, 2)}

```

I want to use all numbers in list to combinations, but itertools didn't do it.

So, I want to get result like this:

```
(0, 0), (0, 1), (0, 1), (1, 0), (1, 0) ...

```

So, since we have two 0 and two 1 we will have two (0, 1) combinations and etc.

Answer: 
A set is a data structure without duplicates. Use a list:

```
import itertools
a = [0, 0, 1, 1, 2, 2]
combinations = list(itertools.permutations(a, 2))
print(combinations)

```
Just use `itertools.product`, it gives all possible combinations:

```
from itertools import product

a = [0, 0, 1, 1, 2, 2]
print (list(product(a, repeat=2)))

```

gives:

```
[(0, 0), (0, 0), (0, 1), (0, 1),
 (0, 2), (0, 2), (0, 0), (0, 0),
 (0, 1), (0, 1), (0, 2), (0, 2),
 (1, 0), (1, 0), (1, 1), (1, 1),
 (1, 2), (1, 2), (1, 0), (1, 0),
 (1, 1), (1, 1), (1, 2), (1, 2),
 (2, 0), (2, 0), (2, 1), (2, 1),
 (2, 2), (2, 2), (2, 0), (2, 0),
 (2, 1), (2, 1), (2, 2), (2, 2)]

```