Reputation: 36367
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 "
Upvotes: 5
Views: 27360
Reputation: 20583
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\"]'"
Upvotes: 4