I have a bunch of math expressions stored as strings. Here's a short one:
stringy = "((2+2)-(3+5)-6)"
I want to break this line down into a list containing ONLY the information in each “infraorbital phrase” (I am sure there is a better way to express this.) Thus, my income will be:
['2+2','3+5']
I have a couple of ideas on how to do this, but all the time I am faced with the “okay now what” problem.
For instance:
for x in stringy: substring = stringy[stringy.find('('+1 : stringy.find(')')+1] stringlist.append(substring)
It just works peachy to return 2 + 2, but this applies as much as possible, and I am completely silent about how to move about the rest ...
source share