I want a line of code which will create an empty list whose name is determined by an incrementing variable.
Everywhere I've looked thus far has been unhelpful. They suggest instead something which makes a list of empty lists or using a dictionary. This is not what I want, I want a line (or several) of code which just creates an empty list (which is not part of a dictionary or a list of lists, a stand alone entity). I want these lists to be distinct, distinguished by a variable which increments by 1 every time a new empty list is created.
These empty lists can't be made in one batch at the very beginning as I intend to make and delete these lists throughout a recursive function. I need to make multiple lists as my intention is for this function to descend to a new level of recursion but return later to the previous list. These are acting as temporary working lists which calculate a value for each item of an original list and then copy the result into a final list once it is found.
str("list_" + i) = []
If i = 1, then I would like this line of code to create an empty list with the name "list_1" which I can proceed to interact with throughout my script.
Instead I'm met with "SyntaxError: can't assign to function call"
By all means let me know if I'm not making any sense at all and I will do my best to convey my request.
defaultdict(list)sounds ideal even though you say it is notlocal_list = []in the body of the function, that will create a separate empty list each time the function is called. It won't share the list with the other calls, either earlier or later, unless you write code to make it do so. Dealing with local variables is much nicer than using globals.