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

Method first

data_structures/linked_list/deque_doubly.py:63–73  ·  view source on GitHub ↗

return first element >>> d = LinkedDeque() >>> d.add_first('A').first() 'A' >>> d.add_first('B').first() 'B'

(self)

Source from the content-addressed store, hash-verified

61
62class LinkedDeque(_DoublyLinkedBase):
63 def first(self):
64 """return first element
65 >>> d = LinkedDeque()
66 >>> d.add_first('A').first()
67 'A'
68 >>> d.add_first('B').first()
69 'B'
70 """
71 if self.is_empty():
72 raise Exception("List is empty")
73 return self._header._next._data
74
75 def last(self):
76 """return last element

Callers

nothing calls this directly

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected