'How to collapse the code section in Google Colab Notebook but keeping the results shown?

As you can read on the title, I'm currently trying to make the code section collapsing without collapsing also the results section. For example without the collapse the title/code/result sections look like this:

Uncollapsed Section in Google Colab Notebook

If I try to "collapse" the section will look like this:

Collapsesed Section in Google Colab Notebook

I'm looking for a solution where I can make collapse the code but not the results sections



Solution 1:[1]

You can start the cell with

#@title

Then, you can double click the title. It will hide the code part, but keep the output still visible.

For example

#@title My title
greet = "Hello"
print(greet)

Double clicking "My title" will still show the output "Hello".

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 korakot