-3

i need a help to remove some characters with python Code :

txt = 'Congo (Congo-Brazzaville)'

can i remove characters starting from ( to )

so that txt after that is like : 'Congo'

2 Answers2

1

Try with re package:

>>> import re
>>> txt = re.sub("\(.*\)", "", txt)
>>> txt
'Congo '
Grzegorz Skibinski
  • 12,624
  • 2
  • 11
  • 34
0

Try replace function:

txt = txt.replace("string", "to be replace with")

YAHYA
  • 1
  • 2