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

Method extend

data_structures/linked_list/print_reverse.py:71–85  ·  view source on GitHub ↗

Appends each item to the end of the LinkedList. >>> linked_list = LinkedList() >>> linked_list.extend([]) >>> str(linked_list) '' >>> linked_list.extend([1, 2]) >>> str(linked_list) '1 -> 2' >>> linked_list.extend([3,4]) >>> str

(self, items: Iterable[int])

Source from the content-addressed store, hash-verified

69 self.head = self.tail = Node(data)
70
71 def extend(self, items: Iterable[int]) -> None:
72 """Appends each item to the end of the LinkedList.
73 >>> linked_list = LinkedList()
74 >>> linked_list.extend([])
75 >>> str(linked_list)
76 ''
77 >>> linked_list.extend([1, 2])
78 >>> str(linked_list)
79 '1 -> 2'
80 >>> linked_list.extend([3,4])
81 >>> str(linked_list)
82 '1 -> 2 -> 3 -> 4'
83 """
84 for item in items:
85 self.append(item)
86
87
88def make_linked_list(elements_list: Iterable[int]) -> LinkedList:

Callers 1

make_linked_listFunction · 0.95

Calls 1

appendMethod · 0.95

Tested by

no test coverage detected