python-by-example-150-chall.../challenges105-110/challenge-110.py

16 lines
416 B
Python
Raw Normal View History

2019-08-01 19:54:19 +08:00
file = open('Names.txt', 'r')
print(file.read())
file.close()
file2 = open('Names2.txt', 'w')
file2.close()
ask = str(input('Enter one of names : '))
with open('Names.txt', 'rt') as myFile:
for myLine in myFile:
if myLine != ask:
file2 = open('Names2.txt', 'a')
file2.write(myLine + '\n')
file2.close()
myFile.close()
file = open('Names2.txt', 'r')
print(file.read())