9

I would like to insert a python variable into a text cell, in google colab.

For example, if a=10, I would like to insert the a into a text cell and render the value.

So in the text cell (using Jupyter Notebook with nbextensions) I would like to write the following in the text cell: There will be {{ a }} pieces of fruit at the reception.

It should show up as: There will be 10 pieces of fruit at the reception.

The markdown cheatsheets and explanations do not say how to achieve this. Is this possible currently?

Nicolas
  • 374
  • 4
  • 18

1 Answers1

4

It's not possible to change 'input cell' (either code or markdown) programmatically. You can change only the output cells. Input cells always require manually change. (even %load doesn't work)

korakot
  • 37,818
  • 16
  • 123
  • 144
  • 3
    This is not what the op is asking for. They're asking for a way to inject a variable's value into some sentence in a text cell. Mixing variables into their words. Unfortunately, @Nicolas Smoll, this does not seem to be possible. I need the same functionality :( – zelusp Dec 09 '19 at 19:40
  • This is simple explanation of a vague and unclear question. Excellent. – prosti Oct 17 '20 at 08:55