'jupyter-notebook markdown for multiline code

I know that in order to include code in jupyter-notebook as markdown (i.e not to be executed), it is possible to enclose it in this symbol (`)

The thing is this only supports short expressions that occur in the same line, what if I want to include something like:

def x(state):
    return state[0] == 'W'

And have it not be executed, and continue with the markdown. Is there a special trick for multiline code?



Solution 1:[1]

use this markdown syntax will work in markdown cell in jupyter.

 ```python    
 def x(state):
    return state[0] == 'W'
 ```

python above is optional.

Solution 2:[2]

I had the same problem today, updating ruby to 3.0.0 seems to solve this problem. Ubuntu for some reason downloads version 2.7.0, I used this article to help me install ruby 3.0.0

https://linoxide.com/how-to-install-ruby-on-ubuntu-20-04/

You will obviously also need to change the version in Gemfile and ruby-version file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 RaghapBean