Is your desired result:
[[1.5, 3.5, 2.1], [[], [], []], [[], [], []]]?
or is it ?
[[[1.5], [3.5], [2.1]], [[], [], []], [[], [], []]]?
because the second one is an equal data structure more likely what you want.
Then you need to not do:
survRates[0] = 1.5
survRates[1] = 3.5
survRates[2] = 2.5
Instead do:
survRates[0] = []
survRates[0][0] = 1.5
survRates[0][1] = 3.5
survRates[0][2] = 2.5
or since you have very specific requirements: it looks like you had a typo in your question: this probably what you really wanted.
survRates = [[[], [], []], [[], [], []], [[], [], []]]
survRates[0][0][0] = 1.5
survRates[0][0][1] = 3.5
survRates[0][0][2] = 2.5
That way each array will be an array with just one element... for I'm sure nefarious purposes.
You were not accurately describing what you wanted:
You wanted to set the position 0 (first element) in a list but not the list of survRates but instead the list in survRates's first element's list (triply nested!). So for nested lists like survRates in order to access the first element of the first list you use: an_array[0][0][0] = just doing an_array[0] = or an_array[0][0] = will attempt to set the first element of survRates not survRates' first list or that list's first list.
This part generates: [[[], [], []], [[], [], []], [[], [], []]]
def gens():
for i in range(totalGens):
dataSet = []
for j in range(3):
dataSet.append([])
newList.append(dataSet)
print(newList)
If you want further help here explain what's going on a bit deeper.
newAdults = juvs * survRates[0][0]
Having a hardcoded survRates[0][0] will return a list not an element probably unlikely that you want to multiply juvs by a list with 3 mathematical elements probably you want survRates[0][0][0] there.
UPDATE ==>
Since they're saying they do particularly want it to have 1 array in the first data list and 3 arrays in each subsequent datalist:
gens() function should be modified:
def gens():
for i in range(totalGens):
dataSet = []
for j in range(3):
if i > 0:
dataSet.append([])
newList.append(dataSet)
print(newList)
now we will have =>
[[], [[], [], []], [[], [], []]]
This part in the beginning of your post will still give an error:
survRates[0] = 1.5
survRates[1] = 3.5
survRates[2] = 2.5
But will work is:
survRates[0][0] = 1.5
survRates[0][1] = 3.5
survRates[0][2] = 2.5