Skip to main content

Tupledict with lists for values

Answered

Comments

1 comment

  • Maliheh Aramon
    Gurobi Staff Gurobi Staff

    Hi Pavithra,

    Let values be the list of the elements, (5, 10, 15, 20, 21) in your example. You can just write:

    d = tupledict([(("Type A", "Time period 1", index), value) for 
    index, value in enumerate(values)])

    Then \(\texttt{d}\) will be:

    {
    ('Type A', 'Time period 1', 0): 5, ('Type A', 'Time period 1', 1): 10,
    ('Type A', 'Time period 1', 2): 15, ('Type A', 'Time period 1', 3): 20,
    ('Type A', 'Time period 1', 4): 21
    }


    Best regards,

    Maliheh

    0

Please sign in to leave a comment.