0

Why is //n here?

6th May 2019, 12:12 PM
Dharmendra Kumar
Dharmendra Kumar - avatar
5 Antworten
+ 1
\n (not /n) is a line break. If you use \n in a string, the text that follows the \n will continue in the next line. \ is an escape character and means that the next character is not to be treated as a special character but as a regular character. Because of the escape character, print('\\n') will print '\n' instead of a line break.
6th May 2019, 12:23 PM
Anna
Anna - avatar
+ 1
Go to the code playground and try this: print('This is\na string') vs this: print('This is\\na string')
6th May 2019, 12:42 PM
Anna
Anna - avatar
0
But in the question there is back slash n and is this different from \n? and I still didn't get u.. I think my question is different..
6th May 2019, 1:26 PM
Dharmendra Kumar
Dharmendra Kumar - avatar
0
And when I write simply it as a string the result is what I guess means only one backslask
6th May 2019, 1:30 PM
Dharmendra Kumar
Dharmendra Kumar - avatar
0
Incase of input the result vary means two back slash is there
6th May 2019, 1:31 PM
Dharmendra Kumar
Dharmendra Kumar - avatar