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 2021 CCC Practice Test Hindi Python Programming Tutorials 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 Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz