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?
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?
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)
To continue processing of the same command to the next line, add a backslash ('\') before a '\n'