Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (55.6k points)

def len_link(lst):

"""Returns the length of the link.

    >>> lst = link(1, link(2, link(3, link(4))))

    >>> len_link(lst)


    >>> len_link(empty)



Hi, can anyone tell me how to find the length of a linked list?

1 Answer

0 votes
by (119k points)

You can also use this:

def len_link(list):

    temp = list.head

    count =0

    while (temp):

        count +=1

        temp =

return count

I recommend enrolling in this Python Course by Intelllipaat to learn Python.

Also, you can watch this video on the linked list in Python:

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Oct 30, 2020 in Python by Sudhir_1997 (55.6k points)

Browse Categories