In terminal if x='xyz \ uv' and then put x after >>>prompt it gives 'xyz \\ uv' but if I use print(X) it gives 'xyz \ uv' | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 3

In terminal if x='xyz \ uv' and then put x after >>>prompt it gives 'xyz \\ uv' but if I use print(X) it gives 'xyz \ uv'

I am unable to understand the reason of difference between the outputs

12th Sep 2020, 4:51 AM
Hemant
Hemant - avatar
1 Respuesta
+ 2
With backslash you can escape special characters, or create newlines (\n) or tabs (\t), so, without the extra backslash you would be escaping the space after it. I don't know why both give different results tho
17th Sep 2020, 10:32 AM
Martín Stanicio