I have this piece of:
As, Bs, Cs, Ds, Es = ([] for i in range(5))
for line in infile:
line = line.rstrip()
a, b, c, d, e = line.split('\t')
As += [a]
Bs += [b]
Cs += [c]
Ds += [d]
Es += [e]
Since I have many more than just 5, I want to do this with a loop that takes up less lines of code than writing all of it out. Something like:
As, Bs, Cs, Ds, Es = ([] for i in range(5))
dynamic_variable_list = [As, Bs, Cs, Ds, Es]
for line in infile:
line = line.rstrip()
for i in range(len(line.split('\t'))):
dynamic_variable_list[i] += line.split('\t')[i]
Which in my case stores individual characters in the list, whereas:
dynamic_variable_list[i] += line.split('\t')
Stores all the tab delimited entries into each of the variables of dynamic_variable_list. What I need is to store all of the tab delimited entries in separate variables as the top example shows.