I am completely new to Python and I have an error I don't understand. I have a function called mult1 which I want to take a list "a" and multiply each element together and output the total so that a list of [1,2,3,4] would output 24. I am getting an error "list index is out of bounds" at line 4
def mult1(a):
n=1
for i in a:
n=n*a[i-1]
print(n)
My function works with the input [1,2,3,4] but not with [7,8,1,2]. Why is this?