Update full linked list example
All checks were successful
Deploy to Homelab / deploy (push) Successful in 7s
All checks were successful
Deploy to Homelab / deploy (push) Successful in 7s
This commit is contained in:
@@ -14,19 +14,19 @@ class LinkedList:
|
||||
head = None
|
||||
tail = None
|
||||
|
||||
def append(Llist, thing):
|
||||
if Llist.head==None:
|
||||
Llist.head=Node(value=thing)
|
||||
Llist.tail=Llist.head
|
||||
return
|
||||
Llist.tail.nextNode=Node(value=thing)
|
||||
Llist.tail=Llist.tail.nextNode
|
||||
def append(self, thing):
|
||||
if self.head==None:
|
||||
self.head=Node(value=thing)
|
||||
self.tail=self.head
|
||||
return
|
||||
self.tail.nextNode=Node(value=thing)
|
||||
self.tail=self.tail.nextNode
|
||||
|
||||
|
||||
list1=LinkedList()
|
||||
append(list1, 'hi')
|
||||
append(list1, 'hi again')
|
||||
append(list1, 'why am I saying hi so many times?')
|
||||
list1.append('hi')
|
||||
list1.append('hi again')
|
||||
list1.append('why am I saying hi so many times?')
|
||||
print(list1.head.value)
|
||||
print(list1.head.nextNode.value)
|
||||
print(list1.head.nextNode.nextNode.value)
|
||||
|
||||
Reference in New Issue
Block a user