I am trying to find the position of all open parentheses in a string. Following this answer, I am able to find the positions of letters, but I cannot find the position of parentheses. For example, l = [3, 4]
, but when I try and find all (
I get error: unbalanced parenthesis
.
import re
s = "(Hello("
l = [m.start() for m in re.finditer('l', s)]
openp = [m.start() for m in re.finditer('(', s)]