Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confused about Python set notation

Tags:

python

I keep getting "IndexError: list assignment index out of range." I'm still trying to get the hang of Python. Why do I get an index error when running the program. Is there a better way to go about this? This is just a chunk out of my code.

T=a=h=FA=[]

i=1

T[i]=10*(.0001)
a[i]=-1
h[i]=(4)/2
FA[i]=function(-1)

I just want to have the sets equal the values at i=1.

like image 910
user3056430 Avatar asked Feb 13 '26 22:02

user3056430


1 Answers

Your list is empty, hence there is no element 1 to replace. Also, they're all bound to the same list. You don't want that.

T=[]
a=[]
h=[]
FA=[]

T.append(10*(.0001))
a.append(-1)
h.append((4)/2)
FA.append(function(-1))
like image 102
Ignacio Vazquez-Abrams Avatar answered Feb 19 '26 00:02

Ignacio Vazquez-Abrams



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!