I am trying to use an `if` statement to check whether a variable has been assigned and is not `None`. 

```
# Code that may or may not assign value to 'variable'

if variable: 
    do things

```

This throws an error at the line with the `if` statement: "UnboundLocalError: local variable 'variable' referenced before assignment". 

I thought if the variable wasn't assigned it would just be interpreted as False? 

I've tried `if variable in locals():` to no avail. 

What's going on? What can I do to achieve the result I'm looking for? 

Thanks