```
def update_basis(A, basis, i, j):
for k, var in enumerate(basis):
idx = int(var[1:])
if A[i][j] == 1:
basis[k] = "x" + str(j+1)
break
return basis
```

I wrote the above code, and I am getting error as stated. I even tried range(enumerate(basis)), after reading one of the answers here. That too doesn’t seem to work. How do I get around this?

PS. I took this code from – https://github.com/pyaf/operations-research/blob/master/simplex-method/utils.py

I know there are many similar questions on this, but I just cant get one that answers me problem.

Source: Python Questions