power = [10, 20, 15, 30, 5]
queries = [[0, 2], [1, 3]]
answer = []
total = 0
start1 = queries[0][0]
end1 = queries[0][1]
start2 = queries[1][0]
end2 = queries[1][1]
for i in range(start1,end1+1):
total += power[i]
answer.append(total)
total = 0
for j in range(start2,end2+1):
total += power[j]
answer.append(total)
print(answer)
To embed this project on your website, copy the following code and paste it into your website's HTML: