Firstly there is the question of getting the right characters into your strings. Then there is the question of how Python displays your string. The same string can be displayed in two different ways.
>>> s = '\\asd'
>>> s
'\\asd'
>>> print(s)
\asd
In this example the string only has one slash. We use two slashes to create it but that results in a string with one slash. We can see that there's only one slash when we print
the string.
But when we display the string simply by typing s
we see two slashes. Why is that? In that situation the interpreter shows the repr
of the string. That is it shows us the code that would be needed to make the string - we need to use quotes and also two slashes on our code to make a string that then has one slash (as s
does).
When you print a list with a string as an element we will see the repr
of the string inside the list:
>>> print([s])
['\\asd']