I am trying to find the most pythonic way to tackle down my problem in the short time as possible since I am dealing with a large amount of data. My problem is the following:
I have two lists
a = [12,34,674,2,0,5,6,8]
b = ['foo','bar','bar','foo','foo','bar','foo','foo']
I want to say python: if 'bar' is in b, take all the indexes and sum all values in list a with those indexes.
This is what I have done so far:
idx = [i for i, j in enumerate(a) if j == 'bar']
but then I am stacked. I am considering using some wired for loops. Do you have any idea?