I know there has been many questions about this already but I just need a small step. I am trying to figure out a way to see if a particular value is within parenthesis or not. I need to store values within parenthesis as negative integers otherwise positive integers. I am using this function but it gives me error for values which are not in parenthesis.
def extract(string, start='(', stop=')'):
return string[string.index(start)+1:string.index(stop)]
Please help.