Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a line-break in Terminal?

I'm using Python in Terminal on Mac OSX latest. When I press enter, it processes the code I've entered, and I am unable to figure out how to add an additional line of code e.g. for a basic loop.

like image 1000
jhealy Avatar asked Mar 04 '11 05:03

jhealy


People also ask

How do I create a multi line command in terminal?

Using a Backslash. The backslash (\) is an escape character that instructs the shell not to interpret the next character. If the next character is a newline, the shell will read the statement as not having reached its end. This allows a statement to span multiple lines.

How do you go to next line in terminal without pressing enter?

Those are regular slashes, not backslashes. Actually using a backslash \ instead would work, and you don't need to shift the enter key.

How do you start a new line in terminal Mac?

All replies. To enter multiple lines before running any of them, use Shift+Enter or Shift+Return after typing a line.

How do I add a line break in bash?

Printing Newline in Bash Using the backslash character for newline “\n” is the conventional way. However, it's also possible to denote newlines using the “$” sign.


1 Answers

The answer here is far more simple. If you want to continue in the next line after a loop like

while b<1:

when you press enter you get prompted with

...

then you "have to make an indent" by space of tab and only then you can put more code after the three dots like

... (tab or space) print b

then when you press enter the code is not going to be executed but you get another ... where you can keep typing you code by making the new indent

keep the indent the same

that is it

like image 142
stdavid Avatar answered Oct 05 '22 13:10

stdavid