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?
4 Respostas
+ 2
oh thats weird idk maybe they just made the python console like that D=
+ 1
it should work ok
msg = "hey\n"
print(msg) #will give u hey then a newline
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
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.