Computer Science, asked by Anonymous, 11 months ago

Write a function in python to count the number of lines in a text file ‘STORY.TXT’ which is starting with an alphabet ‘A’ .​

Answers

Answered by Anonymous
25

f=open('STORY.TXT','w+')

lines=f.readlines()

#traverse this list and compare the first element of the list with A

count=0

for i in lines:

if i[0][0]=='A':

count+=1

f.close()

i hope this works...

but the logic is correct

Similar questions