Saved Bookmarks
| 1. |
Write a function in python to count the number of lines in a text file ‘STORY.TXT’ which is starting with an alphabet ‘A’ . |
|
Answer» def COUNTLINES(): file=open('STORY.TXT','r') lines = file.readlines() count=0 for w in lines: if w[0]=="A" or w[0]=="a": count=count+1 print(“Total lines “,count) file.close() |
|