Skip to main content

TypeError: 'int' object does not support item assignment

Answered

Comments

2 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support.
  • Maliheh Aramon
    • Gurobi Staff

    This error is a Python error and is not related to Gurobi. 

    The error happens when an integer is made to act as a list. For example, the script below will generate the same error as you observed:

    A = [1, 2, 3]
    # A[2] is an integer and cannot be treated as a list
    A[2][0] = 4

    You might want to check the initialization of the \(\texttt{solution.Y}\) attribute in your code to ensure \(\texttt{solution.Y[i][j][k]}\) is a list and not an integer. 

    Best regards,
    Maliheh

    0

Post is closed for comments.