I want to remove the apostrophes from a text file given a certain condition, they aren't surrounded by letters. I've been able to figure out how to get the sum of apostrophes surrounded by letters with the following, using isalpha()
method:
sum(textfile[i-1].isalpha() and textfile[i]=="'" and textfile[i+1].isalpha()
for i in range(1,len(textfiel)-1))
But I would like to remove the apostrophes that are't surrounded in letters somehow, without importing extra modules.
Does anyone have a suggestion on how to use the .isalpha() method for this?
I've had a try using the isalpha()
combined with text.replace()
but it seems hard to achieve.