5

enter image description here

I have the following variable assignment:

xpath_query="xpath='//a[@id="mylink"]'"

This is giving me an error in my pycharm editor and giving a syntax error when I run this code. What am I doing wrong?

when I hold the cursor over the red squiggle it says:"end of statement expected "

1
  • 3
    Hint: Look at the syntax coloring in your question. Commented Oct 17, 2014 at 15:43

1 Answer 1

4

You have double quotes inside your " " block. so it becomes:

"xpath='//a[@id=" <-- stick together with --> "]'"

Hence it is a string syntax error.

To include " inside " " block, you can use \ to escape the character:

xpath_query="xpath='//a[@id=\"mylink\"]'"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.