The resource variable needs to be assigned to None before this if statement:

```python
resource = None
```