Computer Science, asked by vaibhavsharmajnv9, 6 months ago

Write a program that copies a text file “source.txt” onto “target.txt” barring the line started 3

with a “@” sign .

Answers

Answered by Oreki
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