I'm trying to have a function take an array and int as inputs and return an array of the same length after doing some calculations.
I'm completely new to Python and may just be making a very obvious mistake but can't resolve it on my own.
The error message says im out of range but ive tried shortening and expanding the range of the for loop?
def WMA(element, duration):
multiplier = 1 / duration
z = [len(element)]
z[0] = element[0] * multiplier
for k in range(1, len(element) + 1):
z[k] = (element[k] * multiplier) + (z[k - 1] * (1 - multiplier))
return z
Error message:
IndexError: list assignment index out of range