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). Ex: If the input is: input1.txt ammoniated millennium and the contents of input1.txt are: aspiration classified federation graduation millennium philosophy quadratics transcript wilderness zoologists the output is: aspiration classified federation graduation millennium my code is not working im getting an indentation error #input filename filename = open(input()) #input lower bound str1 = input() #input upper bound str2 = input() #read lines from file l = filename.readlines() #heading message print() #for each loop to read line one by one for i in l: #strip line i = i.strip() #check all line between lower and upper bound if str1 <= i <= str2: #print line print(i) #close file filename.close()
Python
Write a
Ex: If the input is:
input1.txt ammoniated millennium
and the contents of input1.txt are:
aspiration classified federation graduation millennium philosophy quadratics transcript wilderness zoologists
the output is:
aspiration classified federation graduation millennium
my code is not working im getting an indentation error
#input filename
filename = open(input())
#input lower bound
str1 = input()
#input upper bound
str2 = input()
#read lines from file
l = filename.readlines()
#heading message
print()
#for each loop to read line one by one
for i in l:
#strip line
i = i.strip()
#check all line between lower and upper bound
if str1 <= i <= str2:
#print line
print(i)
#close file
filename.close()
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 3 images