Write two functions, so that we can find the total number of lines in a collection of text files.
a) The first one takes in the name of a text file as its only parameter, reads the file line by line, and returns the number of lines in the file.
b) The second function repeatedly prompts for a file name until the user signifies no more file names by pressing the Enter key with no characters typed in. For each file name, this function calls the one in (a) above and uses the returned value to accumulates a variable. Once there is no more file name entered, the function returns the accumulated value.
Invoke the second function, from function called main().
def workOnFile&#40;fileName&#41;: counter = 0; with open(fileName) as fid: for line in fid: counter += 1 return counter def calculateLinesCount(): linesCount = 0 fileName = input("Enter a file name: ") while len(fileName) > 0: linesCount += workOnFile&#40;fileName&#41; fileName = input("Enter a file name: ") return linesCount
def main(): print('Total lines count is ' + str(calculateLinesCount())) if __name__ == "__main__": main()