Takes a list of lists and appends 0s to the beggining of each sub_list
    until they are all the same length. Used for sign-extending binary numbers.

def prepend_zeros_to_lists(ls):
    """
    Takes a list of lists and appends 0s to the beggining of each sub_list
    until they are all the same length. Used for sign-extending binary numbers.
    """
    longest = max([len(l) for l in ls])

    for i in range(len(ls)):
        while len(ls[i]) < longest:
            ls[i].insert(0, "0")