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

Method remove_last

data_structures/linked_list/deque_doubly.py:125–143  ·  view source on GitHub ↗

removal in the end >>> d = LinkedDeque() >>> d.is_empty() True >>> d.remove_last() Traceback (most recent call last): ... IndexError: remove_first from empty list >>> d.add_first('A') # doctest: +ELLIPSIS <data_structures.lin

(self)

Source from the content-addressed store, hash-verified

123 return self._delete(self._header._next)
124
125 def remove_last(self):
126 """removal in the end
127 >>> d = LinkedDeque()
128 >>> d.is_empty()
129 True
130 >>> d.remove_last()
131 Traceback (most recent call last):
132 ...
133 IndexError: remove_first from empty list
134 >>> d.add_first('A') # doctest: +ELLIPSIS
135 <data_structures.linked_list.deque_doubly.LinkedDeque object at ...
136 >>> d.remove_last()
137 'A'
138 >>> d.is_empty()
139 True
140 """
141 if self.is_empty():
142 raise IndexError("remove_first from empty list")
143 return self._delete(self._trailer._prev)

Callers

nothing calls this directly

Calls 2

is_emptyMethod · 0.45
_deleteMethod · 0.45

Tested by

no test coverage detected