Question: There might be a similar ask to this one in the past, however wasn't able to find the one that I was looking for,

```
Input = [('Icecream', 'Vanilla'), ('Icecream', 'Chocolate'), ('Icecream', 'Strawberry')]
Output = [('Icecream', ['Vanilla', 'Chocolate', 'Strawberry'])]

```

Basically, given a list of tuples, need to merge the tuples to form a tuple list without duplicates where the second element in each tuple must be a list.

The Input list might contain more items like below,

```
Input = [('Icecream', 'Vanilla'), ('Icecream', 'Chocolate'), ('Icecream', 'Strawberry'), ('Veggie', 'Carrot'), ('Milk', 'whole'), ('Milk', 'formula')]

Output = [('Icecream', ['Vanilla', 'Chocolate', 'Strawberry']), ('Veggie', ['Carrot']), ('Milk', ['whole', 'formula'])]

```

Answer: 
I think the best approach on your problem is to convert ***Input*** in to a *dictionary*.

```
Input = [('Icecream', 'Vanilla'), ('Icecream', 'Chocolate'), ('Icecream', 'Strawberry'), ('Veggie', 'Carrot'), ('Milk', 'whole'), ('Milk', 'formula')]

new_dict = {}
for item in Input:
    key, *values = item
    if key not in new_dict:
        new_dict[key] = []
    new_dict[key].append(*values)
print(new_dict)

```

Output:

```
{'Icecream': ['Vanilla', 'Chocolate', 'Strawberry'], 'Veggie': ['Carrot'], 'Milk': ['whole', 'formula']}

```

Using this approach, you can easily get the items you need:

```
icecream_flavors = new_dict["Icecream"]
print(icecream_flavors)

```

Output:

```
['Vanilla', 'Chocolate', 'Strawberry']

```

But if you really want a *list of tuples* just convert the *dictionary* to a *list*:

```
new_list = list(new_dict.items())
print(new_list)

```

Output:

```
[('Icecream', ['Vanilla', 'Chocolate', 'Strawberry']), ('Veggie', ['Carrot']), ('Milk', ['whole', 'formula'])]

```
Given the assumption that the first item in the tuples will always be the same, this will do what you need.

```py
Input = [('Icecream', 'Vanilla'), ('Icecream', 'Chocolate'), ('Icecream', 'Strawberry')]

flavors = []
for i in Input:
    if i[1] not in flavors:
        flavors.append(i[1])

Output = [(Input[0][0], flavors)]

```