Skip to content

Commit 1d05c39

Browse files
Update doubly_linked_list_two.py
1 parent 6aeb5b8 commit 1d05c39

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: data_structures/linked_list/doubly_linked_list_two.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __next__(self):
3535
raise StopIteration
3636
else:
3737
value = self.current.data
38-
self.current = self.current.get_next()
38+
self.current = self.current.next
3939
return value
4040

4141

@@ -49,15 +49,15 @@ def __str__(self):
4949
nodes = []
5050
while current is not None:
5151
nodes.append(current.data)
52-
current = current.get_next()
52+
current = current.next
5353
return " ".join(str(node) for node in nodes)
5454

5555
def __contains__(self, value: int):
5656
current = self.head
5757
while current:
5858
if current.data == value:
5959
return True
60-
current = current.get_next()
60+
current = current.next
6161
return False
6262

6363
def __iter__(self):
@@ -132,13 +132,13 @@ def get_node(self, item: int) -> Node:
132132
while node:
133133
if node.data == item:
134134
return node
135-
node = node.get_next()
135+
node = node.next
136136
raise Exception("Node not found")
137137

138138
def delete_value(self, value):
139139
if (node := self.get_node(value)) is not None:
140140
if node == self.head:
141-
self.head = self.head.get_next()
141+
self.head = self.head.next
142142

143143
if node == self.tail:
144144
self.tail = self.tail.previous

0 commit comments

Comments
 (0)