The trouble I'm having with this program is that it is not including the bounds even though I use the >= <= operators. Also for some reason the words that are output are each separated by a newline rather than printing one after another.
For example, if the chosen .txt file contains:
Aladdin
Batman
Dinosaurs
Edgar
Fruitloop
Mongoose
and the chosen upper and lower bounds are:
Batman
Fruitloop
The program prints:
Batman
Dinosaurs
Edgar
Here is what I'm working with. Any help is greatly appreciated!
import os
user_file = input() #reads name of user chosen .txt file containing alphabetized one word per line lists
lo_limit = input() #reads a user chosen word as the inclusive lower alphabetical limit
up_limit = input() #reads a user chosen word as the inclusive upper alphabetical limit
file_handle = open(user_file) #opens user chosen file
lines = file_handle.readlines() #creates by-line string of file contents
#if user chosen file contains words equal to or between bounds, prints words
for ln in lines:
if ln >= lo_limit \
and ln <= up_limit:
print(ln)