ipython.display clear_output

from IPython.display import clear_output

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

Here is what the above code is Doing:
1. It’s creating a for loop that iterates 10 times.
2. It’s clearing the output of the cell after each iteration.
3. It’s printing “Hello World!”