I am trying to write some code which will open List1.txt and copy the contents up until it sees the string 'John smith' to List2.txt.
This is what I have so far:
F=open('C:\T\list.txt','r').readlines()
B=open('C:\T\list2.txt','w')
BB=open('C:\T\list2.txt','r').readlines()
while BB.readlines() == 'John smith':
B.writelines(F)
Here is an example of what List1.txt could contain:
Natly molar
Jone rock
marin seena
shan lra
John smith
Barry Bloe
Sara bloe`
However, it doesn’t seem to be working. What am I doing wrong?
1 Answer