Question: Write a function getnlines( filepath ) that returns the number of lines in the provided file whose path has been provided. Your function must read

Write a function getnlines( filepath ) that returns the number of lines in the provided file whose path has been provided.

Your function must read one character at a time and check for the existence of the end-of-line character, .

Consider the following file named news.dat that contains 12 lines:

%%file news.dat (CNN)Betsy Williams recalls being awoken just after 4:30 a.m. Friday by what sounded like gunfire from an automatic weapon.

After Williams called 911 and police cordoned off Second Avenue in downtown Nashville, a "computerized message" from a parked RV captured her attention.

"Evacuate now," Williams remembers the female voice saying -- over and over again.

Williams told CNN hours after the vehicle exploded, injuring three, that she and wife Kim clearly heard another message emanating from the RV. It was a countdown.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!