clear cells in jupyter notebook code example

Example 1: jupyter clear cell output programmatically

from IPython.display import clear_output

for i in range(10):
    clear_output(wait=True)
    print("Hello World!")

Example 2: delete cell in jupyter notebook

D+D(press the key twice when you are in command mode) to delete the selected cell.

Example 3: how to clear all cells in jupyter notebook

Press Esc to enter command mode.
Hold Shift . Select the first and last cells to select all cells. *
Press d twice to delete all selected cells.