Write a function to read a text file stoy.txt and display only those words which are starting with letter ‘a’. use python as answering medium
Answers
Entire text file 2. 1st lines of the text file. 3. m lines starting from the nth line 4. number of words in each line with open("FilemultiLines.txt") as f : print('Entire Content of File is :: \n') print(f.read().strip()) f.seek(0) print('\n 1st n Line of Text File :: \n') print(f.readline().strip()) f.seek(0) m = int(input("\nenter line no. from where you want to start : ")) n = int(input("enter line no. upto where you want to end : ")) print("\nm lines starting from the nth line :: \n") for i in (f.readlines() [m-1:n]) : print(i,end = '' ) print('\n') print('number of words in each line : \n') f.seek(0) for i in f.readlines() : words = len(i.split(' ')) print('Line ',i,' is :: ',words)
Below is the answer to your question