The problem looks (from the error) like it may have something to do with the extra '(' in your selector.
given Given you state the original statement works:
elem2 = driver.find_element_by_xpath("(//a[contains(text(),'Comment')])[3]")
and this is the bad one:
The given selector "(//a[contains(text(),\'Comment\')])[3]"
you can clearly see the difference when lined up. You appear to have an extra '(' at the start.
I believe
xp_str1 = str("\"//a[contains(text(),'Comment')])[")
xp_str2 = str(3)
xp_str3 = str("]\"")
str_elem = xp_str1 + xp_str2 + xp_str3
may fix that. I just tried it quickly in an online interpreter, and it appears to fix it.