0
for i in lista:
lista.append(X)
X = X * 0.5
for i in range(100):
print 'N[%d] = %.4f' %(i, lista[i])
This mistake always happens: Indexerror: list index out of range
0
for i in lista:
lista.append(X)
X = X * 0.5
for i in range(100):
print 'N[%d] = %.4f' %(i, lista[i])
This mistake always happens: Indexerror: list index out of range
Browser other questions tagged python-2.7 list
You are not signed in. Login or sign up in order to post.
You are trying to access an index that does not exist in the variable
lista
.– stderr
The list and the variable "X"
– Artur Rocha
You can edit the question and ask if you want.
– stderr
That’s because the variable
lista
does not have 100 elements...experimente
doprint len(lista)
before the last cycle is to see how many items there are. Anyway to do what you are doing could be more straightforward if you did it soonfor i in lista: ...
where i will be each element that this list contains– Miguel