Write a function that takes in two sorted lists and outputs a sorted  list that is their unionCould anyone help me to improve this code and make it more user-friendly? We are not supposed to use any built-in Python functions, but rather develop our own efficient algorithms.def answer(list1, list2):    len1 = len(list1)    len2 = len(list2)    final_list = []    j = 0    k = 0    for i in range(len1+len2):        if k == len1:            final_list.append(list2[j])            j += 1            continue        if j == len2:            final_list.append(list1[k])            k += 1            continue        if list1[k] < list2[j]:            final_list.append(list1[k])            k += 1        else:            final_list.append(list2[j])            j += 1    return final_listprint answer([1, 2 , 17, 18, 100], [3, 3, 4, 5, 15, 19, 20, 101])
Takes in two sorted lists and outputs a sorted list that is their union
python;performance;sorting;mergesort
You could pick better names for your variables. Definitely answer should be something else, like sorted_union. result would be better than final_list. And list1 and len1 aren't great, though you have limited options there.You should also add a docstring. They're basically string literals that appear at the start of a class or function. They're programmatically accessible comments that will allow you to see what the function does, and you already have one in your brief, so just add the syntax to include it:def answer(list1, list2):    Takes two sorted lists and returns their union as a sorted list.Also since you call for i in range but don't need i, a commonly accepted Python style is to actually use _ instead of i. Using an underscore signals that you don't need the value, it's just there to fit the for loop syntax.You actually could shortcircuit the loop when j or k have reached the end. You know you'll no longer need anything but the rest of list2 in this case:    if k == len1:        final_list.append(list2[j])        j += 1        continueSo why not just use extend to add the rest of list2 on to final_list and break the loop?    if k == len1:        final_list.extend(list2[j:])        break