I'm writing a code that takes movie names and release dates from a txt file and turns it into a dictionary. Then there is two other codes. First code asks the user to type a year and adds the movies released in that year into a list. Second code asks the user for a letter and adds movies starting with that letter(and their release dates) into a list. First code works fine but the second code ignores the if statement and adds all of the movies to the list. This was supposed to happen when I typed "u"
[1996 Unhook the Stars, 2005,Up and Down,1996,Unhook the Stars, 1987,Unsolved Mysteries: Psychics, 2004,Unconstitutional: The War on Our Civil Liberties]
My code is :
movies = {}
years = []
names = []
def load_movies():
    with open("movie_data.txt", "r") as document:
        for line in document:
            (k, v) = line.split(",")
            movies.update({k : (movies[k] if k in movies else []) + [v]})
def get_movies_by_year():
    x = str(input("Enter a year: "))
    for i , t in movies.items():
        if x == i :
            years.insert(1, (t))
    #print_list(years)
def get_movies_by_name():
    o = input("Enter a letter: ")
    for y , q in movies.items():
        for value in q:
            if (value[0]) == o.upper() or o.lower() :
                names.insert(1, (y , value))
    print_list(names)
         
def print_list(e):
    for l in e:
    for w in l:
        print(w.strip("\n"))
load_movies()
get_movies_by_name()
 
    