Code Review

    def remove_element(self,index):
       if index<1:
        print("Invalid Index, Enter a Number  < = 1 ")
       elif index ==1:
          current = self.head
          self.head = current.nextnode
          current = self.head
          count = 0
          while count<index:
              current = current.nextnode
          prev_node.nextnode = current.nextnode

What wrong with the above code
It throws an Error saying " NoneType has no attribute nextnode. "

Should this be tested first to be sure it is not None (tail node)?

1 Like