Q:

indexing error in list in python

B=l.append((l[i]+A+B))

l is a list here and i am trying to append into it more value for it to act as an array . But its still giving me error like list index out of range  . How to get rid of it ?

A:

There are many problems in your code:
1) the append method does not return anything, so it does not make sense to write B = l.append(...)
2) The double parenthesis are confusing, the code you wrote is exactly equivalent to B.append(l[i]+A+B)
3) Finally, obviously, the index i must be a valid index for the list l, otherwise you will get an IndexError exception.

