I need calculate the total sums separately with the values in cluster1. Profit is the first number in each list inside the cluster1 nested list and quantity will be the second number.
The output I expected was 11 with print(totalprofit1)
and 8 with print(totalprofit2)
. However, I got an empty list [] as the output and I am not sure how to fix this.
Below is the current code I have so far:
cluster1=[[1,2],[1,6],[9,0]]
totalprofit1=[]
totalquantity1=[]
for profit,quantity in int1:
if isinstance((profit,quantity), list):
totalprofit1.append(sum(profit))
totalquantity1.append(sum(quantity))
print(totalprofit1)
print(totalquantity1)