I have a text file called 'file.txt' that I want to loop through and remove any line that contains the word 'test'
so I opened the file in 'append' mode:
h = open('file.txt', 'a+')
for l in h:
print('something') #to check if loop works
if 'test' in l:
h.write(l)
But nothing happens and if I try opening it in 'read' mode, i get an error
io.UnsupportedOperation: not writeable
On line 5