Enrollments Open for Certification Course on Artificial Intelligence and Deep Learning by IIT Roorkee
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?
Want to create exercises like this yourself? Click here.
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