I am trying to erase all question marks('?') from a .txt file. I tried tokenizing all content and printing it back like this:
with open('my.txt', 'r') as f:
tokenized = f.split()
for i in len(tokenized):
if tokenized[i] == '?':
tokenized.remove('?')
with open('my.txt', 'w') as f:
f.write(' '.join(tokenized))
but it doesn't remove all question marks and if there are any line breaks or whitespace longer than 1 it removes them.