<commit_before>class Cell(object):
    def __init__(self, item = None, next = None):
        self.item = item
        self.next = next

def dump(linkedList : Cell):
    cell = linkedList

    while True:
        print(cell.item)

        if cell.next == None:
            break

        cell = cell.next

def insert_element_by_index(linkedList : Cell, index : int, element : Cell):
    if index == 0:
        return

    cell = linkedList

    for _ in range(1, index):
        cell = cell.next

    element.next = cell.next
    cell.next = element

if __name__ == '__main__':
    linkedList = Cell(1, Cell(2, Cell(3, Cell(4, None))))
    dump(linkedList)

    insert_element_by_index(linkedList, 2, Cell(100, None))
    dump(linkedList)<commit_msg>[Algorithm Basic] remove last element of linked list<commit_after>class Cell(object):
    def __init__(self, item = None, next = None):
        self.item = item
        self.next = next

def dump(linkedList : Cell):
    cell = linkedList

    while True:
        print(cell.item)

        if cell.next == None:
            break

        cell = cell.next

def insert_element_by_index(linkedList : Cell, index : int, element : Cell):
    if index == 0:
        return

    cell = linkedList

    for _ in range(1, index):
        cell = cell.next

    element.next = cell.next
    cell.next = element

def remove_element_last(linkedList : Cell):
    cur = linkedList
    prev = None

    while cur.next != None:
        prev = cur
        cur = cur.next

    prev.next = None


if __name__ == '__main__':
    linkedList = Cell(1, Cell(2, Cell(3, Cell(4, None))))
    dump(linkedList)

    insert_element_by_index(linkedList, 2, Cell(100, None))
    dump(linkedList)

    remove_element_last(linkedList)
    dump(linkedList)
{'fraction_non_alphanumeric': 0.1067193675889328, 'fraction_numerical': 0.01129305477131564, 'mean_word_length': 2.440776699029126, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6247989', 'n_tokens_mistral': 577, 'n_tokens_neox': 548, 'n_words': 152}