Enrollments closing soon for Post Graduate Certificate Program in Applied Data Science & AI By IIT Roorkee | 3 Seats Left
Apply NowLogin using Social Account
     Continue with GoogleLogin using your credentials
If we know the file is relatively small compared to the size of our main memory, we can read the whole file into one string using the read
method on the file handle.
Example -
fhand = open('/cxldata/datasets/project/mbox-short.txt')
inp = fhand.read()
fhand.close()
number_of_lines
mbox-short.txt
which is located at /cxldata/datasets/project/mbox-short.txt
read
method on file handlePS - If your logic is correct then your function should return 1910
. You can use "Hint" and "See Answer" if you are stuck.
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...