Define a function called countinfile that takes two strings


Reminder: All files must be closed when you are done with them, even if it stops early due to an IOError. If you're using with, this will happen automatically.

If you're trying to close things manually using .close(), this is a lot more complicated.

Define a function called count_in_file() that takes two strings, a filename and a search string, and returns the number of times that the search string occurs in the file.

If no such file exists, or if an IOError occurs while working with the file, the function should return -1.

You must use a for loop to read through the file line-by-line. That means that you cannot use .read(), .readline(), or .readlines().

This is simple python Language please.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Define a function called countinfile that takes two strings
Reference No:- TGS02915711

Expected delivery within 24 Hours