Does anyone know the escape sequence to use a \ in a list.
List = ['a','B','c','D','\'] # My python interpreter thinks I want
# a line continuation but I want the
# actual ASCII character.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This will work,
You “escape” the \ with another \ in front. As an aside, “List” is probably not the best choice for a variable name.
Basically any time you want to use the \ as a simple “\” character and not the
special Python character you have to use two of them.
So for instance, this will look for a single backslash in the list and print a single
backslash, even though two are used in the code.
Output: