Skip to main content

How to add conditionals in quicksum for loop?

Answered

Comments

2 comments

  • Michel Soares
    Thought Leader

    Hi Scott,

    You may try doing this instead:

    quicksum(self.b_plus[j, i, t] for j in range(self.noCells) if j!=i) -
                        quicksum(self.b_minus[i, j, t] for j in range(self.noCells) if j!=i)
    0
  • scott zheng
    First Comment
    First Question

    U r the most clever. That really makes sense.

    Thank you, Michel

     

    0

Please sign in to leave a comment.