'I have different number of quotes to concatinate so make a complete Xpath but getting error,

I am storing 2 strings and concatinating to make a complete xpath for for script

    rowc = driver.find_elements(By.XPATH, '//*[@class="rgRow"]|//*[@class="rgAltRow"]')
    i = len(rowc)
    extstr1 = "//*[@id="m_mc_s0_igSearch_ctl00_ctl00__
    extstr2 = "]/td[13]"
    for i in range(0):
        extval = driver.find_element_by_xpath(extstr1+i+extstr2)

I am getting the below error :

  extstr1 = "//*[@id="m_mc_s0_igSearch_ctl00_ctl00__
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 SyntaxError: invalid syntax. Perhaps you forgot a comma?


Solution 1:[1]

Change your code like this:

extstr1 = "//*[@id='m_mc_s0_igSearch_ctl00_ctl00__'"
extstr2 = "]/td[13]"

You need to change the " in extstr1 into '

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1