Whats wrong with this code? I am totally new to programming, so please dont hate me

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>

<What do you expect to happen instead?>

```python

from gurobipy import *

def solve(n,b,p,a,u,l):

#Model
model = Model("Constrained Knapsack Model")

x={}
for i in range (n) :    #1                  2
   x[i] = model.addVar(vtype=GRB.BINARY, obj = p[i], name="x_%s"% i)
    
#Gewinn maximieren     3
model.modelSense = GRB.MAXIMIZE

# model aktualisieren, um die Variablen bekannt zu machen
model.update()

# ergaenzen Sie ab hier die linearen Nebenbedingungen (aka constraints)
                                       #4
model.addConstr(quicksum(x[i]*a[i] for i in range(n))  <=b,
name='capacity')

#Maximalanzahl an Gegenstaenden
model.addConstr(quicksum(x[i] for i in range(n)) <=u,
name=“maximum”)

#Minimalanzahl an Gegenstaenden
model.addConstr(quicksum(x[i] for i in range(n)) >=1,
name=“minimum”)

# Solve
model.update()
model.optimize()


return model
<do not remove the three backticks above>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.