I have 5 empty lists list1=[], list2=[], list3=[], list4=[], list5=[]
and list with 5 variable var_list=[v1, v2, v3, v4, v5]
. I want to append each variable inside var_list
inside a corresponding empty list. I do that work manually:
list1.append(var_list[0])
list2.append(var_list[1])
list3.append(var_list[2])
list4.append(var_list[3])
list5.append(var_list[4])
I want to do that in for loop, I known the elements of var_list
can be called inside loop as var_list[i]
, but how can I call list
in such way, where all variables list
with same name and different in numbers. 'list'+str(i)
cannot work. Can anyone please help me to do this work in one line inside loop.