What is the difference between '\' and '\n' escape sequence in python

I am coming from C language

In book of Python it is given

among escape sequence

\ - New line in a multi-line string

\n - Line break

I am confused and unable to differentiate between the two.


You have completely misread the book.

\ is not an escape sequence, and is not used on its own in strings. It is used in multi-line code.

\n is a newline character in strings.


\ - New line in a multi-line string

It is used for splitting a string which has a vast number of characters into multi lines as it is inconvenient to write in a single line. This is something that has effect in the code only.

\n - Line break

This one on the other hand is a typical line break statement for printing something in a new line. The same thing we use in C and C++ languages. this is something that has effect in the output.