Need to check I'm understanding this right.
I'm running a function that appends lists to a list in a nested dictionary. I thought I would be able to assign a variable to append and return the same values as the nested dictionary, but it returns 'None', (and interestingly still appends the nested dictionary even though it's in an append function that returns None?)... so is the best way of returning the nested values by using multiple/nested .get()
functions as below?
scores = {"class1": {'nest1':{'nest2':[]}}}
get_nested_list = []
test_var = []
def main():
for i in range(0,3):
test_var.append(scores["class1"]['nest1']['nest2'].append([i,i+1,i+2]))
main()
get_nested_list = scores.get("class1").get('nest1').get('nest2')
print(test_var)
print(get_nested_list)
Output...
[None, None, None]
[[0,1,2],[1,2,3],[2,3,4]]