Check to find and count How many vowels from file
This is the program, I have practice today...
Input:
how are you? I'am fine
Output:
This file contains 9 times use vowels word.
Program:
for Python 3...
a = open("samplefile.txt") #open file...
count = 0
for line in a: #picking up each line by line from file...
b = len(line) #calculate each line length then, these length store in another variable...
for i in range(b): #picking up each letter from file in line...
if(line[i]=='a' or line[i]=='e' or line[i]=='o' or line[i]=='i' or line[i]=='u'): #check each letter is vowel or not...
count = count+1 #count how many time use vowels...
print("This file contains %s times use vowels word"%(count)) #print vowel counts...
a.close() #close file...
This is the program, I have practice today...
Input:
how are you? I'am fine
Output:
This file contains 9 times use vowels word.
Program:
for Python 3...
a = open("samplefile.txt") #open file...
count = 0
for line in a: #picking up each line by line from file...
b = len(line) #calculate each line length then, these length store in another variable...
for i in range(b): #picking up each letter from file in line...
if(line[i]=='a' or line[i]=='e' or line[i]=='o' or line[i]=='i' or line[i]=='u'): #check each letter is vowel or not...
count = count+1 #count how many time use vowels...
print("This file contains %s times use vowels word"%(count)) #print vowel counts...
a.close() #close file...
---------------------------
This program is contains few basic logics...
- python basics
- file manipulation
- find string length using inbuild function len()
- find string length without using inbuild function otherwise using count method
- check to search specified word is exist or not in file
Comments
Post a Comment