I copied a long text from a webpage including several Python code sections and text sections into my Jypter notebook. Below what I copied and pasted.
Is there any straightforward way to convert the code sections to executable Code cell and leave the rest text as Markdown instead of inserting new cell one by one for the code sections? (codes and texts are in separated paragraphs). Below what I want:
Thank you for your time in advance.
If it is just a few lines as in your example, the manual way is most convenient. Paste everything in one cell, and then split the cell by using a keyboard shortcut for that (Ctr-Shift-Minus) and use another keyboard shortcut (M) to change the types of cells with comments in it to Markdown.
If you have lots of material to convert, Jupytext might help. https://github.com/mwouts/jupytext .