The following code gives me the error
"unbalanced parenthesis at position 22"
This error is triggered at line change = re.search(word[indice], contenu)
. I manage to remove the parentheses in the "contenu" variable but the error persists. Do you know what this could be due to?
import re
myTxt= open('MyFile.txt')
contenu = myTxt.read()
contenu = contenu.replace("\"","\\\"")
contenu = contenu.replace("\'", "\\\'")
contenu = contenu.replace(")", "")
contenu = contenu.replace("(", "")
for indice in range(0,len(word)):
change = re.search(word[indice], contenu)
if change != None:
re.sub(word[indice], aRemplacer[indice], contenu)
myTxt.close()
"word" and "aRemplacer" are two tables previously created on my notebook, so the error does not come from forgetting to instantiate these variables.
Thank you in advance for any answers.