File Pgms
File Pgms
Occurences
k=0
for line in f:
words = line.split()
for i in words:
if(i==word):
k=k+1
print(k)
2.Vowels
def read_and_count():
lower_case=0
upper_case=0
alphabet=0
space=0
digit=0
string_count=0
c=iv.readlines()
for j in c:
for i in range(len(j)):
if(j[i].isalpha()):
alphabet+=1
if(j[i].isdigit()):
digit+=1
if(j[i].islower()):
lower_case+=1
if(j[i].isupper()):
upper_case+=1
space+=1
string_count+=j.lower().count("hai")
print("Alphabets : ",alphabet)
print("Space : ",space)
print("Digits : ",digit)
read_and_count()
3.SEARCH
contents = file.read()
search_word = input("enter a word you want to search in file: ")
if search_word in contents:
else:
4.Merging
data = fp.read()
data2 = fp.read()
# Merging 2 files
data += "\n"
data += data2