We use the string method
startswith to select only those lines with the desired prefix.
The below code prints the lines starting with
fhand = open('/cxldata/datasets/project/mbox-short.txt') count = 0 for line in fhand: line = line.rstrip() # Remove new line characters from right if line.startswith('From:'): print(line)
Write a function
count_number_of_lines which returns the count of the number of lines starting with
Subject: in the file
PS - If your logic is correct then your function should return 27. You can use "Hint" and "See Answer" if you are stuck.
No hints are availble for this assesment
Answer is not availble for this assesment
Note - Having trouble with the assessment engine? Follow the steps listed here