Build a Linked List - Step 12

class LinkedList:
    class Node:
        def init(self, element):
            self.element = element
            self.next = None
def __init__(self):
    self.length = 0
    self.head = None

def is_empty(self):
    return self.length == 0

def add(self, element):
    node = self.Node(element)
    if self.is_empty():
        self.head = node
    else:
        current_node = self.head
        while current_node.next != None:
            current_node = current_node.next
my_list = LinkedList()
print(my_list.is_empty())

whenever i run the code it just says ‘You should create a while loop that checks whether current_node.next is not None.‘ What should i do.

What is the difference between checking if something equals None versus checking if something is None?

1 Like

I understand now. Thanks, this helped a lot :folded_hands: !

1 Like