"\h\h" Why this returns '\\h\\h' inside python ? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

"\h\h" Why this returns '\\h\\h' inside python ?

15th Jan 2021, 2:33 PM
Gautam Yadav
Gautam Yadav - avatar
3 Respostas
+ 3
Do you mean? The "\\h\\h" is the input. And the "\h\h" is output. Then it is because backslash are used for escaping characters, so here the interpreter will recognize that "h" is being escaped by the backslash before it. And so If you want to print the backslash itself, then you also have to escape it (the backslash) Or you can just use the "r" prefix for strings r means raw or raw string For example: print( "\\n\\n" ) >> \n\n print( r"\n\n" ) >> \n\n
15th Jan 2021, 4:22 PM
noteve
noteve - avatar
15th Jan 2021, 4:50 PM
Gautam Yadav
Gautam Yadav - avatar
0
ā™¤ā™¢ā˜ž šŠš¢š¢š›šØ š†š”ššš²ššš„ ā˜œā™¢ā™¤ well, it not happens with print. Never mind I searched and got my answer, anywas thanks for trying :)
15th Jan 2021, 3:52 PM
Gautam Yadav
Gautam Yadav - avatar