Pass a variable in IPython / Jupyter to a block of html (%%html)

Viewed 2422

I would like to pass a simple variable to an html cell on Jupyter:

cell 1:

a=5

cell 2:

%%html
<html>
  <head>
    <script type="text/javascript">
    window.alert(a);
    </script>
  </head>
</html>

This will return an error:

Javascript error adding output!
ReferenceError: a is not defined
See your browser Javascript console for more details.
1 Answers
Related