How to Run a Cell in Jupyter Notebook Only If a Value Is Null?

22 Replies, 2177 Views

Hey! If you’re looking for a way to jupyter notebook run a cell if a value is null without any output when the value isn’t null, you can use `display` from `IPython`.

```python
from IPython.display import display, clear_output

if some_value is None:
display("Value is null, doing stuff now!")
else:
clear_output()
```

This will clear the output if the value isn’t null, so it looks like the cell didn’t run at all.

Messages In This Thread



Users browsing this thread: 1 Guest(s)