I have created a dictionary which I have assigned the first element of a list as a key. I would like to append the rest of the elements as values to the dictionary:
file_a contains tab delimited fields.
a = {}
for line in file_a.readlines():
split_line = line.strip().split('\t')
a[split_line[0]] = []
a[split_line[0]].append(split_line[::-1]) # append from second to last element to the list
The ::-1 appends all the elements. I need to append all elements except the first one (as that is used as a key). Any help will be appreciated.
e.g. if fields are: X\t1\t2\t3 I would like the hash to be:
'X': ['1', '2', '3']