I am pretty new to python and looking for how to create a list of empty lists having names more efficiently than presented below
I would like to have some names to the lists.
flattenlist_x1 = [] flattenlist_x2 = [] flattenlist_x3 = [] flattenlist_x4 = [] flattenlist_x5 = [] flattenlist_x6 = [] flattenlist_x7 = [] flattenlist_x8 = [] flattenlist_x9 = [] flattenlist_x10 = [] flattenlist_x11 = [] flattenlist_x12 = [] flattenlist_list = [flattenlist_x1, flattenlist_x2, flattenlist_x3, flattenlist_x4, flattenlist_x5, flattenlist_x6, flattenlist_x7, flattenlist_x8, flattenlist_x9, flattenlist_x10, flattenlist_x11, flattenlist_x12]
Advertisement
Answer
Beacuse you want it to have name, how about using dict?
flattenlist_list = {} for i in range(1,13): flattenlist_list['flattenlist_x'+str(i)]=[] print(flattenlist_list)