def length(head) -> int:
    '\n    The method length, which accepts a linked list\n    (head), and returns the length of the list.\n    :param head:\n    :return:\n    '
    i = 0
    if (head is None):
        return 0
    while (head.next is not None):
        head = head.next
        i += 1
    return (i + 1)
The method length, which accepts a linked list
(head), and returns the length of the list.
:param head:
:return:
def length(head) -> int:
    '\n    The method length, which accepts a linked list\n    (head), and returns the length of the list.\n    :param head:\n    :return:\n    '
    i = 0
    if (head is None):
        return 0
    while (head.next is not None):
        head = head.next
        i += 1
    return (i + 1)