Write a function in python that displays the number of lines starting with ‘H’
in the file
“para.txt”. Example, if file contains:
Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow
Then the lines count should be
Answers
Answered by
3
Answer:
def countH():
f = open ("Para.txt", "r")
lines =0
l =f.readlines()
for i in l:
ifi[0]=='H':
lines+=1
print "no. of lines is",lines
Similar questions
India Languages,
2 months ago
Geography,
2 months ago
Math,
2 months ago
English,
5 months ago
Math,
5 months ago
English,
11 months ago
Social Sciences,
11 months ago
Biology,
11 months ago