Python Forum
Please help: Index out of range error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please help: Index out of range error
#1
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
Reply
#2
You need to format your code in code tags and re-post.
Please read BBCODE

Thank you
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pyscript index error while calling input from html form pyscript_dude 2 980 May-21-2023, 08:17 AM
Last Post: snippsat
  Index error help MRsquared 1 766 May-15-2023, 03:28 PM
Last Post: buran
Thumbs Down I hate "List index out of range" Melen 20 3,319 May-14-2023, 06:43 AM
Last Post: deanhystad
Exclamation IndexError: Replacement index 2 out of range for positional args tuple - help? MrKnd94 2 6,362 Oct-14-2022, 09:57 PM
Last Post: MrKnd94
  IndexError: list index out of range dolac 4 1,913 Jul-25-2022, 03:42 PM
Last Post: deanhystad
  I'm getting a String index out of range error debian77 7 2,349 Jun-26-2022, 09:50 AM
Last Post: deanhystad
  IndexError: list index out of range Anldra12 2 1,442 May-03-2022, 01:39 PM
Last Post: Anldra12
  matplotlib x axis range goes over the set range Pedroski55 5 3,209 Nov-21-2021, 08:40 AM
Last Post: paul18fr
  IndexError: list index out of range rf_kartal 6 2,848 Sep-07-2021, 02:36 PM
Last Post: Larz60+
  Python Error List Index Out of Range abhi1vaishnav 3 2,309 Sep-03-2021, 08:40 PM
Last Post: abhi1vaishnav

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020