Question 14 Marks
Aarti is new in python data-handling. Please help her to count the number of lines which begins with ‘W’ or ‘w’ in poem.txt.
(a) # Line 1 : To open file POEM.txt in read mode
(b) # Line 2 : To check first character of every line is ‘W’ or ‘w’.
(c) # Line 3 : To increase the value of count by 1.
(d) # Line 4 : To call the function count_poem.
Answer
View full question & answer→(a) file1 = open("POEM.TXT","r")
(b) r1[0]=='W' or r1[0]=='w':
(c) count=count+1
(d) count_Poem()