[Answer]-Django can't assign to operator

1👍

These 3 lines have several problems:

    s.number - l = answer
    for 1 in answer:
    List.objects.create(shippingList=s)

One is the indentation: after : the next line must be indented further.

Other is that the control variable is actually a number! That is a 1 not an l.

Other is that the left side of the first line is not assignable, because it is the result of a computation, not a name. I think you have the assignment mirrored.

And other is that answer (if it is intended to be a number) is not iterable; you probably want to use range.

Something like:

    answer = s.number - l
    for i in range(answer):
        List.objects.create(shippingList=s)

Leave a comment