So I am trying to loop over a list of list names and trying to assign value to its element by index.
But the problem is within the loop, it is being referred to as a string literal instead of a list which throws up errors. Below is the snippet of the code I am dealing with.
placeholder_list=["cat_list","cat_list"]
for i in range(len(list_Col)):
specific_function_output
placeholder_list[i][int(index)]=specific_function_output
The problem comes at this step:
the python is interpreting placeholder_list[i]
as "cat_list"
, what I was expecting is
cat_list[int(index)]
but it is actually being treated as "cat_list"[int(index)]
which is genrating the generic error
TypeError: 'str' object does not support item assignment
This might have a very simple solution, but I am having a bit of a struggle to find a solution for this. And also having not too familiar with the technical terms or details about the backdrop doesn't help.
In general, for programming, how should we get the actual instance by referring back to their tokenize names by the index within a loop -- this is how I could conceptualize the problem. But again, I might be missing some technical details on it.