Fix #173: Bugs in linked list append and delete methods (#184)

This commit is contained in:
Emmanuel Arias
2017-04-16 19:11:45 -03:00
committed by Donne Martin
parent fcd4e52e91
commit 1d2b138344
2 changed files with 10 additions and 9 deletions

View File

@@ -33,7 +33,7 @@ class LinkedList(object):
return None
node = Node(data)
if self.head is None:
self.head = Node(data)
self.head = node
return node
curr_node = self.head
while curr_node.next is not None:
@@ -57,7 +57,7 @@ class LinkedList(object):
if self.head is None:
return
if self.head.data == data:
self.head = None
self.head = self.head.next
return
prev_node = self.head
curr_node = self.head.next