Alexander Ivanov
Alexander Ivanov

Reputation: 325

How to insert code output in jupyter notebook markdown cell?

I have a markdown cell with text, and I want it to include some output from the code. For example, I have a variable a in Python that equals to 10, and I want that a markdown cell print something like this:

We have the variable a=10...

without me specifically writing down 10

Upvotes: 10

Views: 8520

Answers (1)

gehbiszumeis
gehbiszumeis

Reputation: 3711

You need to have the jupyter notebook extensions installed. There is an extension called Python Markdown which allows you to do what you want.

In your case you wrap your variable a with curly brackets {{a}}. This will lead to

enter image description here

The code in the markdown cell resulting in "We have tha variable a=10" is accordingly:

We have the variable a={{a}}.

Upvotes: 7

Related Questions