Python Forum

Full Version: Please help: Index out of range error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I receive the Index out of range error for c variable with the following code:

import bumpy as np
x = np.random.normal(mu=0.03,std=0.05,T = 10)

def form(x,w,B):
for i in range(len(x)):
a=[]
c=[]
d=[]
f=[]
if len(x) == 1:
a.append(x[i] - w)
c.append((1 + x[i] - a[i])*1)
d.append((1+x[i])*1)
if d[i] > max(c[:]):
f.append(B+a[i])
else:
f.append(B)
else:
a.append(x[i] - w)
c.append((1 + x[i] - a[i])*c(i-1))
d.append((1+x[i])*c(i-1))
if d[i] > max(c[:-1]):
f.append(B+a[i])
else:
f.append(B)
return f
You need to format your code in code tags and re-post.
Please read BBCODE

Thank you