Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a multi line input in ipython?

I am reading the book Python Data Science Handbook by Jake VanderPlas. In the first chapter a multi line input in ipython is illustrated:

multiLineInput

Can anybody please tell me, how to do that? I know how to write a block before executing it in Jupyter Notebook, but in the ipython shell I don't no how to do it. Thanks for your help!

like image 270
aurumpurum Avatar asked Oct 28 '19 16:10

aurumpurum


People also ask

How do I get multi-line input?

To create a multi-line text input, use the HTML <textarea> tag. You can set the size of a text area using the cols and rows attributes. It is used within a form, to allow users to input text over multiple rows.

How do you input multiple lines in a Jupyter Notebook?

In order to enter more than one statements in a single input cell, press ctrl+enter after the first line. Subsequently, just pressing enter will go on adding new line in the same cell. To stop entering new lines and running cell, press enter key one more time at the end.


2 Answers

ctrl+o

If you type ctrl+o, you should be able to add additional lines to the input to run them simultaneously.

If that doesn't work, as a workaround, you can paste multiple lines after copying them from elsewhere, or you can press enter on a line with a semicolon or unclosed parentheses. IPython will automatically give you another line to finish your statement rather than running and instantly hitting a syntax error.

like image 130
AreToo Avatar answered Oct 13 '22 01:10

AreToo


Use 'shift' + 'Enter' at the end of line to avoid execution and keep typing your code. When you are done writing your block of code hit 'Enter' Have a look to the following picture If for some reason shift doesn't work, Ctrl + Enter instead. I hope this helps, good luck.

like image 23
ZAnteneh Avatar answered Oct 13 '22 01:10

ZAnteneh