Aymptotic Notation Python Sort a Linked List -- object type not a list

Undertaking this task I have realised there is something fundamental about linked lists I don’t understand.

In the “while” loop, why does

while linked_list.get_head_node():

work, whilst

while len(linked_list) > 0:

does not?

Isn’t linked_list as an object of the class LinkedList a list type?

This is the called function’s code:

def sort_linked_list(linked_list):
  print("The original linked list is:\n{0}".format(linked_list.stringify_list()))
  new_linked_list = LinkedList()
  while linked_list.get_head_node():
    maximum = find_max(linked_list)
  return new_linked_list

How would len know what length means for your custom data type?

In particular, you probably shouldn’t expect something to work without being able to say in detail what steps are being carried out for it to work.