0

Query About new line escape character

In print statement whenever you use \n, it just create new line but whenever you use in string it gives \n with output. But it is not the same case as with other escape character like double quote or backslash etc. why is it so?

14th Jan 2017, 6:04 PM
Gaurav
Gaurav - avatar
4 ответов
+ 2
oh thats weird idk maybe they just made the python console like that D=
14th Jan 2017, 6:42 PM
Kawaii
Kawaii - avatar
+ 1
it should work ok msg = "hey\n" print(msg) #will give u hey then a newline
14th Jan 2017, 6:13 PM
Kawaii
Kawaii - avatar
0
But you are storing that in a variable and then again printing it. it's not my query My Query is in the following statement: when you type statement 1: >>>print("Hi\n N3tw0rk") Hi N3tw0rk statement 2: >>>"Hi \n N3tw0rk" 'Hi \n N3tw0rk' statement 3: >>>print("Hi \"N3tw0rk\"") Hi "N3tw0rk" statement 4: >>>"Hi \"N3tw0rk\"" 'Hi "N3tw0rk"' See the difference in all statements
14th Jan 2017, 6:24 PM
Gaurav
Gaurav - avatar
0
I don't want to enter new line i just wanted to know why using escape sequence \" in statement 4 interpreted as " but in statement 2 \n is interpreted as such.
14th Jan 2017, 6:26 PM
Gaurav
Gaurav - avatar