How to parse a string in python? -
I am trying to parse a string. As if this is the string "(A (B (CD) (EF)) (GH)) ", then I want to parse it like the children of A are B and G, near B Children are C and E, and no one has any child, so I want to get the output to be ['A_B_G', 'B_C_E']
I do something like that I am:
lst = [] Str = (A (B) (EF)) (GH)) lst.append (str.split ('')) And then I'm stuck!
Can someone give me an idea of what to do next?
I'm not too much a signal, but you can list the same
You can start by changing the ['(', 'A', '(', 'B', ...] , Such as (, ) or a letter.
Comments
Post a Comment