I have a list of length L
, with some random values:
list1 = [3, 1, 1, 6, 8, 3, 7, 4, 8, 4]
and another list of the same length, with boolean values
list2 = [0, 0, 0, 1, 1, 1, 0, 0, 0, 0]
I want to sum the values of list1
where the corresponding element of
list2
is 1
. (in this case 6+8+3)
is there an easy way to make it in Python?