Yeah I found some documentation on this, and HTML
is actually a class, not a function.
So the correct code would be
from IPython.display import HTML
myhtml = HTML("""<div>One</div><div>Two</div>""") #make the html object
myhtml #display it
Now it makes sense why your code displays only one div.
To display multiple parts create multiple variables, containing the html and then concatenate them inside one call to HTML.
div1 = """<div>One</div>"""
div2 = """<div>Two</div>"""
myhtml = HTML(div1 + div2)
myhtml
Edit:
I opened a ticket on ipython's github profile to see if it's a bug or a feature that only the last line of statements is displayed. Turns out, it's planned behaviour:
quoting Thomas Kluyver:
This is deliberate, because if you call something in a for loop that returns a value:
for line in lines: f.write(line) # Returns number of bytes written
You probably don't want to see all those numbers in the output.
The rule in IPython is: if the last statement in your code is an expression, we display its >value. 1;2 is a pair of statements, whereas 1,2 is one statement, so both values will >display.
I hope that explains things a bit. We're happy to revisit decisions like this, but it's >been this way for years, and I don't think anyone has taken issue with it.