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
|
head = None
|
||||||
tail = None
|
tail = None
|
||||||
|
|
||||||
def append(Llist, thing):
|
def append(self, thing):
|
||||||
if Llist.head==None:
|
if self.head==None:
|
||||||
Llist.head=Node(value=thing)
|
self.head=Node(value=thing)
|
||||||
Llist.tail=Llist.head
|
self.tail=self.head
|
||||||
return
|
return
|
||||||
Llist.tail.nextNode=Node(value=thing)
|
self.tail.nextNode=Node(value=thing)
|
||||||
Llist.tail=Llist.tail.nextNode
|
self.tail=self.tail.nextNode
|
||||||
|
|
||||||
|
|
||||||
list1=LinkedList()
|
list1=LinkedList()
|
||||||
append(list1, 'hi')
|
list1.append('hi')
|
||||||
append(list1, 'hi again')
|
list1.append('hi again')
|
||||||
append(list1, 'why am I saying hi so many times?')
|
list1.append('why am I saying hi so many times?')
|
||||||
print(list1.head.value)
|
print(list1.head.value)
|
||||||
print(list1.head.nextNode.value)
|
print(list1.head.nextNode.value)
|
||||||
print(list1.head.nextNode.nextNode.value)
|
print(list1.head.nextNode.nextNode.value)
|
||||||
|
|||||||
Reference in New Issue
Block a user