print("{ }:{ }:{ }format(filenamelinoline rstrip())we begin by checking that there are at least two command-line arguments if there are notwe print usage message and terminate the program the sys exit(function performs an immediate clean terminationclosing any open files it accepts an optional int argument which is passed to the calling shell reading and writing text files sidebar we assume that the first argument is the word the user is looking for and that the other arguments are the names of the files to look in we have deliberately called open(without specifying an encoding--the user might use wildcards to specify any number of fileseach potentially with different encodingso in this case we leave python to use the platform-dependent encoding the file object returned by the open(function in text mode can be used as an iteratorreturning one line of the file on each iteration by passing the iterator to enumerate()we get an enumerator iterator that returns the iteration number (in variable lino"line number"and line from the fileon each iteration if the word the user is looking for is in the linewe print the filenameline numberand the first characters of the line with trailing whitespace ( \nstripped the enumerate(function accepts an optional keyword argumentstartwhich defaults to we have used this argument set to since by conventiontext file line numbers are counted from quite often we don' need an enumeratorbut rather an iterator that returns successive integers this is exactly what the range(function provides if we need list or tuple of integerswe can convert the iterator returned by range(by using the appropriate conversion function here are few exampleslist(range( ))list(range( ))tuple(range( - - )([ ][ ]( - - )the range(function is most commonly used for two purposesto create lists or tuples of integersand to provide loop counting in for in loops for examplethese two equivalent examples ensure that list ' items are all non-negativefor in range(len( )) [iabs( [ ] while len( ) [iabs( [ ] + in both casesif list was originallysay[ - - - ]afterward it will be [ since we can unpack an iterable using the operatorwe can unpack the iterator returned by the range(function for exampleif we have function called calculate(that takes four argumentshere are some ways we could call it with arguments and