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

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad