w3ajay

tally tutorial point, ms word 2013, ms excel 2013, ms powerpoint 2010,ccc question with answer in hindi 2021, Tally Prime in hindi , tally prime,Python,in python,programming in python,python

Thursday, July 18, 2024

#Remove all the lines that contain the character 'a' in a file and write it to another file



#Remove all the lines that contain the character 'a' in a file and

#write it to another file

f=open("ram.txt")

f1=open("sita.txt","w")

f2=open("durga.txt","w")

data=f.readlines()

for i in data:

    if 'a' in i:

        f1.writelines(i)

    else:

        f2.writelines(i)

f1.close()

f2.close()

f.close()

 

No comments:

Post a Comment

for more information please share like comment and subscribe