I am writing code to sum the second index in a list within a list:
employees = [[1, 5, [2, 3]], [2, 3, []], [3, 3, []]]
i.e. I want to do 5+3+3= 11
for i in range(len(employees)):
total_importance = sum(input[i][1])
or
total_important = sum(map(list.append, input[i][1]))
print(total_importance)
Now both of the options above for total_importance produce an error- int object is not itterable or other errors. Is there any way I can amend the code above for it to work?
I have another method where I simply append input[i][1] into a new list and then sum from there, and this easily works. But for my knowledge I want to ask if there is any way to amend either of the code above? Thanks