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.
Full traceback error:
TypeError Traceback (most recent call last)
<ipython-input-7-9809e74f4f64> in <module>
120 print("\nIteration number : %d" % iter_num)
121 #updating basis as variables enter and leave
--> 122 basis= update_basis(i,j,basis,nonbasic)
123 #updating table
124 A,b,c= row_operations(A,b,c,i,j)
<ipython-input-7-9809e74f4f64> in update_basis(A, basis, i, j)
76
77 def update_basis(A, basis, i, j):
---> 78 for k, var in enumerate(basis):
79 idx = int(var[1:])
80 if A[i][j] == 1:
TypeError: 'int' object is not iterable