Use `enumerate`:
```python
for i, book in enumerate(tab.books(self.course)):
```