Creating multiple cells in a loop

I’d like to create multiple cells in a loop. I received the following snippet from AI. But it is not working JupyterLab. Any Idea how to change it?

from IPython.display import display, Javascript
    
def loop():
    num_cells = 2
    for _ in range(num_cells):
        display(Javascript("Jupyter.notebook.insert_cell_below('markdown', source='Hello World')"))

I am receiving the following error

Javascript Error: Jupyter is not defined
Javascript Error: Jupyter is not defined

Summarizing what is covered in ‘How to programmatically add serveral [sic] new cells in a notebook in JupyterLab’, a lot of the old ‘tricks’/‘exploits’ that worked in older versions of Jupyter Notebook (specifically 6.5 and below) don’t work in JupyterLab or Jupyter Notebook 7+ as the underlying tech is has a different architecture and has fancier abilities and features. (If some of that information about the Jupyter landscape is news to you, see the links in the second half of my answer here.)

You’ll see here that you can programmatically add cells to JupyterLab in a different way now, using ipylab.
Also note it should work in Jupyter Notebook 7+ as specified here by jtpi0:

" @giswqs this likely works in Jupyter Notebook 7 since it’s based on JupyterLab, but probably not in VS Code."

Is there any known way to do similar things with VSCode notebook / Databricks Notebook etc? Frankly I am not familiar with the protocol, just trying to build a minor plugin that end up in a rabbit hole to support different favours of notebook.