MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / remove

Method remove

data_structures/linked_list/__init__.py:77–87  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

75 self.size += 1
76
77 def remove(self) -> Any:
78 # Switched 'self.is_empty()' to 'self.head is None'
79 # because mypy was considering the possibility that 'self.head'
80 # can be None in below else part and giving error
81 if self.head is None:
82 return None
83 else:
84 item = self.head.item
85 self.head = self.head.next
86 self.size -= 1
87 return item
88
89 def is_empty(self) -> bool:
90 return self.head is None

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected