1

When I am entering a string input that contains line breaks, Python thinks that I have pressed Enter and continues to the next commands.

How can I put \n when Enter is pressed, to send the rest to an extra line?

Yaron
  • 10,166
  • 9
  • 45
  • 65
  • 2
    Possible duplicate of [Python 3: receive user input including newline characters](http://stackoverflow.com/questions/2542171/python-3-receive-user-input-including-newline-characters) – Yevhen Kuzmovych Jan 29 '17 at 12:15

2 Answers2

1

In python, if you have a paragraph to execute without a break, Use triple quotes . Here's is an example :

para_str = """this is a long string that is made up of
several lines and non-printable characters such as
TAB ( \t ) and they will show up that way when displayed.
NEWLINEs within the string, whether explicitly given like
this within the brackets [ \n ], or just a NEWLINE within
the variable assignment will also show up.
"""
print (para_str)
Yaron
  • 10,166
  • 9
  • 45
  • 65
0

To continue processing of the same command to the next line, add a backslash ('\') before a '\n'

AndreyS Scherbakov
  • 2,674
  • 2
  • 20
  • 27