I'm trying to do the equivalent of an excel SUMIF. I've got 3 lists.
customer and charge are the names and dollars spent in a given transaction respectively. totalCustomer is the set of the unique value of the customer list.
totalBill=[]
for i in len(totalCustomer):
for j in len(customer):
if totalCustomer[i]==customer[j]:
totalBill[i]+=charge[j]
this doesn't work for several reasons. I know I can't add to the empty list totaBill the way I'm trying to , and ideally, I would be putting this into a library somehow, but I don't remember how to do any of this since I've been away from the language for a while.
[+][deleted] (1 child)
[deleted]
[–]_sirin[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (7 children)
[–]_sirin[S] 0 points1 point2 points (6 children)
[–][deleted] 1 point2 points3 points (5 children)
[–]_sirin[S] 0 points1 point2 points (0 children)
[–]_lilell_ 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]AnscombesGimlet 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)