So for your exact requirement you might have to roll your own class.

Insteead of giving you an answer I'd like to ask you some questions first, as they are

important to find the best solution for your exact use case.

will the list always be alphabetically sorted?

If yes, then you could change above code by changing line 6 from

```
for elt, count in c.items():
```

to```
for elt, count in sorted(c.items()):
```

If not:

Let s assume

L = ['T2','T2','T3','T2','T2',

Would following output be satisfying for you?

```
L = ['T2','T2A','T3','T2B','T2C','T1','T3A']
```

or do you insist on```
L = ['T2A','T2B','T3A','T2C','T2D','T1','T3B']
```

Could L ever be something like =

```
L = ['T2','T2','T3','T2','T2','T1','T3', 'T2A']
```

How would you like to handle this situation? (Unification of T2 would result in T2A and this would mean, that T2A would now exist twice.should the last 'T2A' become 'T2AA'?