Skip to main content

comparison of the values of two dictionnaries



1 comment

  • Jaromił Najman
    Gurobi Staff 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

    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):


    Best regards, 


Please sign in to leave a comment.