Challenge 1: Length of a Linked List

Find the length of the given linked list.

Problem Statement

Implement a function that takes a linked list testVariable and returns the length of the linked list.

Input

  1. A variable testVariable containing the linked list whose length needs to be calculated.
  2. The head node of the linked list head.

Output

Length of the input linked list

Sample Input

testVariable => 3 -> 4 -> 7 -> 11 -> None
head => 3

Sample Output

4

Try it Yourself

Try to attempt this challenge by yourself before moving on to the solution. Good luck!

Press + to interact
main.py
linkedList.py
node.py
import linkedList as l
def length(testVariable, head) :
# Write your code here
return None

In the next lesson, we have a solution review of this problem.