so I have the file: data2.txt
Lollypop,
Lolly pop,
ooh
lolly,
lolly, lolly;
lollypop, lollypop,
ooh lolly, lolly, lolly,
lollypop!
ba dum dum dum ...
LOL :-)
i need to loop through each line of data2.txt printing only lines that contain the string 'lol' and print the output to a newfile
with open("data3.txt") as g:
with open("data2.txt") as lfp:
for lin in lfp:
if 'lol' in lin:
g.write(str(lin))
elif 'LOL' in lin:
g.write(str(lin))
elif 'Lol' in lin:
g.write(str(lin))
But I keep getting error:
g.write(str(lin))
io.UnsupportedOperation: not writable