vluos
vluos

Reputation: 29

Getting error on if and elif

Does anyone know why I keep getting an error with this section of my code?

 if db_orientation2 =="Z":
            a="/C=C\"
 elif db_orientation2=="E":
            a="\C=C\"

This is the error:

File "<ipython-input-7-25cda51c429e>", line 11
    a="/C=C\"
         ^
SyntaxError: EOL while scanning string literal

The elif is highlighted as red as if the operation is not allowed...

Upvotes: 1

Views: 160

Answers (1)

Moses Koledoye
Moses Koledoye

Reputation: 78554

String literals cannot end with a backslash. You'll have to double it:

a="/C=C\\"
#       ^

The highlighting of your code also clearly shows the problem.

Upvotes: 4

Related Questions