from collections import defaultdict 
Null = None
list1 = [(12, "AB"), (12, "AB"), (12, "CD"), (13, Null), (13, "DE"), (13, "DE")]

keys = []
for k,v in list1:
    if k not in keys:
        keys.append(k)
        
intermediate = defaultdict(list)
for k, v  in list1:
    if v not in intermediate[k]:
        intermediate[k].append(v)

list2 = []
for k in keys:
    list2.append([k] + intermediate[k])
    
print(list2)