Error in python(pyomo)

hello,
I wrote a optimization model in python and it said ‘‘there is a invalid syntax’’, its my constraint, but when I delete it , the error goes to next one, it didnot get error to first constraint. What should I do?
model.C2 = ConstraintList()
for a in model.a:
for j in model.j:
for k in model.k:
for g in model.g:
for t in model.t:
model.C2.add(sum(model.X [j,g,k,l,d,t] for d in model.d for l in model.l) == sum(model.beta[a,j,k] * model.AGR[a,f,g,k,l,t] for f in model.f for l in model.l))

Forgive me if I misunderstand, but the syntax above looks odd.
Perhaps the posting has obscured the required indentation.
May I suggest you select the code block and use the
click on the preformatted-text or type (Cntrl-E) to preserve the
actual indenting? Thanks.

Hello,

Thank you, I had indentation in the code, but still have the error!

Fleshing out your question a little bit we get an error as
there is just not enough data provided to make the error
you see.

For best results, code snippets should be minimal size yet
complete and generate the
error you are seeing… (not always easy to do, of course).

It is often helpful to simplify the code (lesser number of
for loops) to see if the error exists, even though
it no longer is quite what you mean or need to do.
As an experiment I mean.

The snippet below is not sufficiently complete to get the error you get…

import pyomo.environ as pe
import collections
model= pe.ConcreteModel()
model.C2 = pe.ConstraintList()
for a in model.a:
    for j in model.j:
        for k in model.k:
            for g in model.g:
                for t in model.t:
                    model.C2.add(sum(model.X [j,g,k,l,d,t] \
                    for d in model.d for l in model.l) == \
                    sum(model.beta[a,j,k] * model.AGR[a,f,g,k,l,t] \
                    for f in model.f for l in model.l))

I know the above is not actually helpful (sorry) but maybe just
making a minimal runnable source version will reveal the problem
to you! I hope this note somehow helps a little.