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

Method last

data_structures/linked_list/deque_doubly.py:75–85  ·  view source on GitHub ↗

return last element >>> d = LinkedDeque() >>> d.add_last('A').last() 'A' >>> d.add_last('B').last() 'B'

(self)

Source from the content-addressed store, hash-verified

73 return self._header._next._data
74
75 def last(self):
76 """return last element
77 >>> d = LinkedDeque()
78 >>> d.add_last('A').last()
79 'A'
80 >>> d.add_last('B').last()
81 'B'
82 """
83 if self.is_empty():
84 raise Exception("List is empty")
85 return self._trailer._prev._data
86
87 # DEque Insert Operations (At the front, At the end)
88

Callers

nothing calls this directly

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected