Write a program that first reads in the name of an input file, followed by two strings representing the lower and upper bounds of a search range. The file should be read using the file.readlines() method. The input file contains a list of alphabetical, ten-letter strings, each on a separate line. Your program should output all strings from the list that are within that range (inclusive of the bounds).

Respuesta :

Answer:

filepath = 'Iliad.txt'

start = 'sometxtstart'

end = 'sometxtend'

apending = False

out = ""

with open(filepath) as fp:

   line = fp.readline()

   while line:

       txt = line.strip()

       if(txt == end):

           apending = False

       if(apending):

           out+=txt + '\n'

       if(txt == start):

           apending = True                

       line = fp.readline()

print(out)

The program illustrates the use of file and file operations

  • First, the program gets the file name as input
  • Then the lower and upper bound of the search range
  • Then the program reads each line of the input file
  • On each line, the program checks if the number is within the search range
  • The number is printed, if the above condition is true

At the end of the program, all numbers in the file within the search range are printed

See attachment for further explanation

Read more about files and file operations at:

https://brainly.com/question/15004613

ACCESS MORE