"\h\h" Why this returns '\\h\\h' inside python ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

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

15th Jan 2021, 2:33 PM
Gautam Yadav
Gautam Yadav - avatar
3 Answers
+ 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
+ 1
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