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