Defining multiple objects based on size of two lists (python)
I am trying to find a way of creating objects based on the size of two
lists. I have to create an object for each combination of indices of the
two lists, i.e. if both lists is of the length 3, 9 new objects should be
created and defined.
The lists can be of rather large lengths and it would make the script a
lot nicer if I did not have to use an if loop to go through all possible
combinations.
A first I thought I could do the following:
for i in range(len(list1)):
for j in range(len(list2):
Name_of_Object+[i]+[j] = (object definition)
But this is not possible and I get the following error:
SyntaxError: can't assign to operator
But is there a way of creating objects based on indices of a list?
Best, Martin
(I am using the Canopy environment to do my python programming.)
No comments:
Post a Comment