1 comment

• Gurobi Staff

Please note that this is not a Gurobi question but a general Python question and should be and should be rather posted in a Python forum instead of here.

Anyway, you are overwriting your $$\texttt{dvar}$$ values with $$0$$. For example, when you check for $$\texttt{Order[1][4]}$$ and $$\texttt{Aisle_arct[1][0]}$$, you will temporarily have a value of $$\texttt{dvar[1,1]=L}$$. However, the last comparison for $$\texttt{i=1, k=1}$$ is  $$\texttt{Order[1][12]='d'}$$ $$\neq$$ $$\texttt{'g'=Aisle_arct[1][4]}$$ and thus you get $$\texttt{dvar[1,1]=0}$$.

I don't know what you want to do with the $$\texttt{dvar}$$ dict, but one way (probably not the most pythonic one) to get only the matching characters would be

dvar={}for i in Order:    for k in Aisle_arct:        dvar[i,k] = []        for z in Order[i]:            for j in Aisle_arct[k]:                if (z==j):                    dvar[i,k].append(z)print(dvar)

Best regards,
Jaromił