- Write a program that copies a text file “Source.txt” onto “target.txt” barring the lines starting with a “@” sign.
Click Here for Solution - Write a user-defined function in Python that displays the number of lines starting with the letter ‘H’ in the file Para.txt, if the file contains.
Click Here for Solution
from os import path
ReplyDeleteif 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('U'):
target.write(sentence)
print("Task executed successfully!")
else: print("Some files seem to be missing...")