The problem I'm facing is being able to take an string like "((1+4)) + (2-1) - 3" and turn it in a list with [((1+4)), (2-1), 3] in it. This would also apply to other amount of parentheses. I tried doing it with indexes and counting parentheses with no luck. Here is some code I have so far:
final = []
while("(" in string):
final.append(string[string.index("("):string.index(")")+1])
left = string[:string.index("(")]
right = string[string.index(")")+1:]
string = string.replace("+", ";")
string = string.replace("-", ";")
string = string.split(";")
for item in string:
if item.strip() != "":
final.append(item)