jumlah python atas indeks tertentu

# You can use sum directly after indexing with indices:
a = np.array([1,2,3,4])
indices = [0, 2] 
a[indices].sum()
# Result: 4
Powerful Penguin