Write a program that copies a text file “source.txt” onto “target.txt” barring the line started 3
with a “@” sign .
Answers
Answered by
6
from os import path
if path.isfile("source.txt") and path.isfile("target.txt"):
with open("source.txt", 'r') as source:
with open("target.txt", 'w') as target:
for sentence in source.readlines():
if not sentence.startswith('@'):
target.write(sentence)
print("Task executed successfully!")
else: print("Some files seem to be missing...")
Similar questions
Accountancy,
3 months ago
Social Sciences,
6 months ago
Accountancy,
6 months ago
Chemistry,
10 months ago