Ask Question
2 August, 18:13

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).

+5
Answers (2)
  1. 2 August, 20:57
    0
    def func (filename, lower, upper):

    file = open (filename, 'r'). readlines ()

    for i in range (int (lower), int (upper)):

    print (file[i]. rstrip ())

    func ('strings','2','4')

    Explanation:

    file is provided below, name: strings in text format

    appleelppa

    banananana

    cattaccatt

    dogdogdogd

    elephanttn

    froggorffr

    goattaoggo

    horseesroh

    illiterate

    jumppmujju
  2. 2 August, 22:09
    0
    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)
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “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 ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers