How to add comments with the code output in jupyter notebook?

Hello,

I am going through one of the guided projects in python course and i am trying to add comments and links with the code output but i don’t know how to do that.

In the code example in the images there are comments and link accompanying the output of the code and i can’t figure out how to do it.

Can some help plz?

1 Like

Hey @adel.abdallah2790,

There are two types of cells in the jupyter notebooks:

  • Markdown
  • Code

To select the cell, select the drop down list under the “Widgets” menu bar.

For Markdown cell, You can either follow this link I found on github or google for markdown.

Also @Mary’s post on markdown is available too.

For Code cell, you have to use # symbol to in front of code to comment.

# This is a comment
print(“my comment”)

If you want to add comments to the output. You have to print the code. That is,

print(“These labels includes start but does not include end”)
outputs: These labels includes start but does not include end

1 Like

Hi @alvinctk,

I have tried the print function with comments and it worked, yet i still can not figure how to add a link like the ones we do in Markdown cells Word.

Any idea how to add the link to the output of the code like in the screenshots?

Many thanks :slight_smile:

From stackoverflow, to output clickable link on the jupyter output:

from IPython.core.display import display, HTML
display(HTML("""<a href="https://www.google.com">text_google</a>"""))

Or in a markdown cell:

[blue text](link)

blue text
Remove all the spaces between ](, since discourse uses markdown too.

Hi @adel.abdallah2790,

What you are seeing in the Dataquest solution is a combination of Output and Markdown Cell.

The confusion is understandable, the way GitHub chose to render the Jupyter notebook kind of makes the output and markdown cell to appear as one. Let me show you how it appears when you work on the Jupyter notebook file.

I hope this has clarified the confusion. In case you want to experiment, this is the markdown code used in the above markdown cell.

We have 7197 iOS apps in this data set, and the columns that seem interesting are: `'track_name'`, `'currency'`, `'price'`, `'rating_count_tot'`, `'rating_count_ver'`, and `'prime_genre'`. Not all column names are self-explanatory in this case, but details about each column can be found in the data set [documentation](https://www.kaggle.com/ramamet4/app-store-apple-data-set-10k-apps/home).


## Deleting Wrong Data

The Google Play data set has a dedicated [discussion section](https://www.kaggle.com/lava18/google-play-store-apps/discussion), and we can see that [one of the discussions](https://www.kaggle.com/lava18/google-play-store-apps/discussion/66015) outlines an error for row 10472. Let's print this row and compare it against the header and another row that is correct.
1 Like

Hey @adel.abdallah2790,

We have a solved feature that allows you the ability to mark something as the “correct” answer, which helps future students with the same question quickly find the solution they’re looking for.

Here’s an article on how to mark posts as solved - I don’t want to do this for you until I know that solution/explanation works.