I have a text that has the following schema:
word1:word2
word3:word4
...
I would like to remove the last part
, a
I'd recommend using a regex replace for this instead of what you're currently using.
import re
def main():
fileR=open('test.txt','r')
for line in fileR:
line = re.replace(r'
$','',line)
print line
Or, if you want, you can just replace all of them at once before printing out each line individually because python's regex is global by default.
import re
def main():
fileR=open('test.txt','r')
fileR = re.replace(r'
$','',fileR)
for line in fileR:
print line