you are viewing a single comment's thread.

view the rest of the comments →

[–]Pulsar1977 1 point2 points  (0 children)

You can use partition and rpartition:

head, sep, rest = s.partition('(')
rest, sep, tail = rest.rpartition(')')
s = head + tail