This is a lot more complicated than the way it's written in the book. Just write

```py
if all((derivation(f, DE) + b*f).is_zero for f in F):
    dc = -1
else:
    dc = 0
```

Or even 

```py
dc = -1 if all((derivation(f, DE) + b*f).is_zero for f in F) else 0
```

If you're worried about efficiency, don't be. `all` short circuits, and by using a generator comprehension instead of a list comprehension (notice that there are no `[` and `]`), it checks each item as it computes it, so no `derivation(f, DE) + b*f` is computed as soon as one of them is non-zero.