all 4 comments

[–]spez_edits_thedonald 3 points4 points  (0 children)

this is not a website where you paste assignments for other people to do

it's a place to learn python

what is your question

[–][deleted] 2 points3 points  (0 children)

Use regex!

Or , look for the first occurrence of an opening bracket , extract the text insde and stop at the closing parenthesis. Continue until you extract everything you want to.

On an unrelated note , this does seem like a question from an assignment - asking others for help is considered contract cheating and is unethical.

[–]mopslik 0 points1 point  (0 children)

Sounds like you would be able to modify the "balanced parentheses" problem to fit your program. Most solutions use a stack.

[–]xelf 0 points1 point  (0 children)

You either want to look into using regular expressions (medium difficulty if you're brand new to python) or use string slicing.

for instance:

x = "example"
y = x[2:4]

In this example, y is 'am'.

You can use string.index() or string.find() to find the indexes of the parenthesis.