Enrollments Open for Certification Course on Artificial Intelligence and Deep Learning by IIT Roorkee

  Apply Now

Searching in Files

We can search in the file line by line or by creating a single string for the whole content of the file.

check = 0
with open("/cxldata/python_sample_file") as f:
    for line in f:
            check = check + 1

startswith function checks if the string is starting with the argument mentioned in the brackets.

Basically, here were searching for the lines in the file which are starting with 'w'.

Can you tell the value of check after the above code is executed?

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

Loading comments...