I am hoping to find way to append only the unique item numlookup and wholetoken. Is there a good way to do this?
numlookup = defaultdict(list) 
wholetoken = defaultdict(list)
#mydata is file containing mutation description
mydata = open('/mutation_summary.txt')
for line in csv.reader(mydata, delimiter='\t'):
    code = re.match('[a-z](\d+)[a-z]', line[-1], re.I)
    if code: 
        numlookup[line[-2]].append(code.group(1))
        wholetoken[line[-2]].append(code.group(0))
When i try to use set i got this as error when i call lookup(id) and wholelookup(id): TypeError: 'set' object is not callable
lookup =set()
wholelookup =set()
with open('mutation_summary.txt') as mydata:
    for line in csv.reader(mydata, delimiter='\t'):
        code = re.match('[a-z](\d+)[a-z]', line[-1], re.I)
        if code: 
            lookup.add(code.group(1))
            wholelookup.add(code.group(0))
 
    