I have to make function where by inputting minimal and maximal 'lasting of the movie', client gets printed out every movie whose lasting is in that range. Now, when I input (as a minimal) two-digit number and (as a maximal) three-digit number, it always says that 'No movie was found', but for example, when I input (for both minimal and maximal) two-digit or three-digit number, the range works, and it prints out movies that belong in that range. I've done this:
list_of_movies = []
def movie_list():
with open("film.txt","r") as f:
all_h = ["name","genre","lasting","director","main role","country","year","description"]
for r in f.readlines():
dicct = {}
bla = r.strip().split("|")
count = 0
for i in bla:
dicct[all_h[count]] = i
count += 1
list_of_movies.append(dicct)
movie_list()
def lasting():
x=False
lasting_min = input("Input minimal lasting: ")
lasting_max = input("Input maximal lasting: ")
for r in list_of_movies:
if r["lasting"] >= lasting_min and r["lasting"] <= lasting_max:
print()
print("Name of the movie: ", r["name"])
print("Genre: ", r["genre"])
print("Lasting: ",r["lasting"],"minutes")
print("Director: ",r["director"])
print("Main roles: ",r["main role"])
print("Country: ",r["country"])
print("Year: ",r["year"])
print("-------------------------------")
x=True
if x==True:
print()
else:
print()
print("No movie was found. ")
print()
lasting()
And btw, I made dicts and lists so I dont have to open the txt file everytime I need something from it.