CBSE BOARD XII, asked by sguru1002, 5 months ago

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 rohannayak2369
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