Please read up a bit on how Python iterators & list comprehensions work. Your use of `range(len(...))` works but it's unnecessarily complex.

I think the following would work just as well:

```python
opinion_ids = [data["id"] for data in op_opinions]
start_opinion_id = min(opinion_ids)
exit_optinion_id = max(opinion_ids)
```