Clearing the current cell in the notebook

In python, you can clear the output of a cell by importing the IPython.display module and using the clear_output function

from IPython.display import clear_output

print("text to be cleared")

clear_output() 

As you can see, the text "text to be cleared" is not displayed because the function clear_output has been called afterward