I wrote this task as below: s='hey (come) go' re.sub('[\(].*?[\)]', '', s) The output is: 'hey go' But if s='hey (come) go (flat)' then the 'go' is deleted too. How can I write code that output should be 'hey go'
Activity
DavidNemeskey commentedon Sep 27, 2017
I just tried the second substitution and it does what it ought to do: it returns
'hey go '.gowould only be deleted if you omitted the question mark:sevinjyolchuyeva commentedon Sep 27, 2017
Yes, you are right :)