def normalize_database(non_normalized_db_filename):
#     Normalize 'non_normalized.db'
#     Call the normalized database 'normalized.db'
#     Function Output: No outputs
#     Requirements:
#     Create four tables
#     Degrees table has one column:
#         [Degree] column is the primary key
    
#     Exams table has two columns:
#         [Exam] column is the primary key column
#         [Year] column stores the exam year
    
#     Students table has four columns:
#         [StudentID] primary key column 
#         [First_Name] stores first name
#         [Last_Name] stores last name
#         [Degree] foreign key to Degrees table
        
#     StudentExamScores table has four columns:
#         [PK] primary key column,
#         [StudentID] foreign key to Students table,
#         [Exam] foreign key to Exams table ,
#         [Score] exam score

     
    ### BEGIN SOLUTION
    #  
    conn_normalized = create_connection('normalized.db', True)

    create_table_Degree_sql = """create table if not exists [Degrees] (Degree TEXT NOT NULL PRIMARY KEY);"""

    create_table(conn_normalized, create_table_Degree_sql)

    create_table_Exam_sql = """create table if not exists [Exams](Exam TEXT NOT NULL PRIMARY KEY, Year INT NOT NULL);"""
    create_table(conn_normalized, create_table_Exam_sql)

    create_table_students_sql = """CREATE TABLE if not exists [Students] (StudentID INT NOT NULL PRIMARY KEY, First_Name TEXT NOT NULL, Last_Name TEXT NOT NULL, Degree TEXT, FOREIGN KEY(Degree) REFERENCES Degrees(Degree));"""
    create_table(conn_normalized, create_table_students_sql)

    create_table_studentexamscores="CREATE TABLE if not exists StudentExamScores (PK INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, StudentID INTEGER, Exam TEXT ,Score INT, FOREIGN KEY(StudentID) REFERENCES Students(StudentID),FOREIGN KEY(Exam) REFERENCES Exams(Exam));"

    create_table(conn_normalized, create_table_studentexamscores)


    conn_non_normalized = create_connection('non_normalized.db', False)
    rows = execute_sql_statement("select * from Students;", conn_non_normalized)

    select_degree='''SELECT DISTINCT Degree FROM Students'''
    degrees=execute_sql_statement(select_degree,conn_non_normalized)

    def insert_degrees(conn_normalized, values):
        sql = ''' INSERT INTO Degrees(Degree)
                VALUES(?) '''
        cur = conn_normalized.cursor()
        cur.execute(sql, values)
        return cur.lastrowid

    select_exams='''SELECT DISTINCT Exams FROM Students'''
    exams=execute_sql_statement(select_exams,conn_non_normalized)

    a = []
    exams = list(map(lambda row: row[0].strip().split(', '), exams))
    for exam in exams:
        for row in exam: 
            exam_name, year_str = row.split(' (')
            year = int(year_str[:-1])
            a.append((exam_name, year))
    b = list(set(a))
    b = sorted(b)

    def insert_Exams(conn_normalized, values):
        sql = ''' INSERT INTO Exams(Exam, Year)
                VALUES(?,?) '''
        cur = conn_normalized.cursor()
        cur.execute(sql, values)
        return cur.lastrowid
    

    select_students= 'select StudentID, Name, Degree from Students'
    Students = execute_sql_statement(select_students, conn_non_normalized)
    Students = []
    for stud in rows:
        StudentID = int(stud[0]) 
        Last_Name = stud[1].split(',')[0]
        First_name = stud[1].split(',')[1]
        Students.append((StudentID, First_name.strip(), Last_Name.strip(), stud[2]))
    

    def insert_Students(conn_normalized, values):
        sql = ''' INSERT INTO Students(StudentID, First_Name, Last_Name, Degree)
                VALUES(?,?,?,?) '''
        cur = conn_normalized.cursor()
        cur.execute(sql, values)
        return cur.lastrowid


    select_scores="SELECT StudentID,Exams,Scores FROM Students;"
    scores=execute_sql_statement(select_scores,conn_non_normalized)
    
    student_score_list = []
    for i in scores:
        l,p,k=i
        ex_scores=k.split(",")
        ex_name=p.split(",")
        for exam,sc in zip(ex_name,ex_scores):
                student_score_list+=[((l,exam.strip().split(" ")[0],float(sc)))]
    
    def insert_StudentExamScores(conn_normalized,values):
        sql='''INSERT INTO StudentExamScores(StudentID,Exam,Score) VALUES(?,?,?) '''
        cur=conn_normalized.cursor()
        cur.execute(sql, values)
        return cur.lastrowid


    with conn_normalized:
        for degree in degrees:
            insert_degrees(conn_normalized,degree)

    with conn_normalized:
        for stud in Students:
            insert_Students(conn_normalized,stud)
    
    with conn_normalized:
        for ex in b:
            insert_Exams(conn_normalized,ex)
    with conn_normalized:
        for i in student_score_list:
            insert_StudentExamScores(conn_normalized,i)

can you rewrite the above function into another way but functionality should remain same also you can change variable names to meaningful ones