Error: int object is not iterable, how to resolve this?

  python, simplex
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)
    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 –
I know there are many similar questions on this, but I just cant get one that answers me problem.

Source: Python Questions