python - How to split with multiple bracket -


so want "(1.0)" returns ["1","0"] "((1.0).1)" returns ["(1.0)", "1")

how do python?

so want break string "(1.0)" list [1,0] dot separator.

some examples

((1.0).(2.0)) -> [(1.0), (2.0)]

(((1.0).(2.0)).1) -> [((1.0).(2.0)), 1]

i hope more clear.

here version:

def countpar(s):     s=s[1:-1]     openpar=0     (i,c) in enumerate(s):         if c=="(":             openpar+=1         elif c==")":             openpar-=1         if openpar==0:             break     return [s[0:i+1],s[i+2:]] 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -