Programming Examples

Python program to copy the all word which start with constant in another file


Write a python program to copy the words from text file Lily.txt into an empty file Rose.txt which start with a consonant.

Solution

fp=open("Lily.txt","r")
data=fp.read()
fp1=open("Rose.txt","w")
output=""
str1=data.split()
for word in str1:
    if word[0].lower() not in ['a','e','i','o','u']:
        output=output+word+" "
fp1.write(output)
print("data copied")
fp.close()
fp1.close()
Output

data copied

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad