title: how to remove Syntax error for constraints in pulp in python
body: <p>The below code shows syntax error after for loop at this line</p>
  <pre><code>model += x[int((str((i*2)-1)+str(j)))] + x[int((str(i*2)+str(j)))]] &lt;= 1
  </code></pre>
  <p>i want the variable to be declared like 2 D array x11, x12,x13 am i getting error because of this.</p>
  <pre><code>KeyError   
  Traceback (most recent call last)
  &lt;ipython-input-95-19b3a6e81910&gt; in &lt;module&gt;()
       19 for i in range (1, (Box//2)+1):
       20      for j in range (1,Pallet+1):
  ---&gt; 21        model += x[int((str((i*2)-1)+str(j)))] + x[int((str(i*2)+str(j)))] &lt;= 1
       22 
       23 
  
  KeyError: 11
  </code></pre>
  <p>i checked all possible option everything seems right someone please help.</p>
  <p>'''</p>
  <pre><code>from pulp import *
  Box=6
  Pallet=3
  Variable_range=Box*Pallet
  
  from pulp import LpMaximize, LpProblem, LpStatus, lpSum, LpVariable
  # Define the model
  model = LpProblem(name=&quot;Container Loading&quot;, sense=LpMaximize)
  
  # Define the decision variables
  for i in range(1, Box+1):
      for j in range (1,Pallet+1):
        x = {int((str(i)+str(j))):LpVariable(name=f&quot;x{i}_{j}&quot;,lowBound=0,upBound=1,cat='Integer')}
        print(x)
  
  # Add constraints
  for i in range (1, (Box//2)+1):
       for j in range (1,Pallet+1):
         model += x[int((str((i*2)-1)+str(j)))] + x[int((str(i*2)+str(j)))]] &lt;= 1 # error at this line
          
  
  #Set the objective
  model += lpSum(x.values())
  
  # Solve the optimization problem
  status = model.solve()
  
  # Get the results
  print(f&quot;status: {model.status}, {LpStatus[model.status]}&quot;)
  print(f&quot;objective: {model.objective.value()}&quot;)
  
  for var in x.values():
      print(f&quot;{var.name}: {var.value()}&quot;)
  
  
  for name, constraint in model.constraints.items():
      print(f&quot;{name}: {constraint.value()}&quot;)
  </code></pre>
  <p>'''</p>