Build a Linked List - Step 12

Tell us what’s happening:

getting this error: You should create a while loop that checks whether current_node.next is not None.

isn’t it already doing as it asked or is the answer right under my nose

Your code so far

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

# User Editable Region

        else:
            current_node = self.head
            while current_node != None:
                current_node = current_node.next

# User Editable Region


my_list = LinkedList()
print(my_list.is_empty())

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0

Challenge Information:

Build a Linked List - Step 12

Github Link: freeCodeCamp/curriculum/challenges/english/blocks/workshop-linked-list-class/68c0da2df8ce865dcf7769a7.md at main · freeCodeCamp/freeCodeCamp · GitHub

Hi @damii-auDHD,

The tests are expecting the “is not” object identity comparison here.

Happy coding!