How can I display the value (as a string) of a python variable in the markdown cell output in the Python Interactive pane of VS Code's MS Python extension?
For a variable var
, using
#%%
from IPython.display import display, Markdown
var = 50 # units
display(Markdown('The value of my variable `var` is: {} units.'.format(str(var)))
in a code cell produces the correct output, but I was looking for a more elegant solution that will allow me to insert the value directly into markdown text.
Something similar to the Jupyter notebook extension Python Markdown.
To show output-number [10]
with the following is inconsistent, and when it does work only outputs all of the code text as plain text.
#%% [markdown]
Out[10]