Skip to content

Instantly share code, notes, and snippets.

@mentix02
Created December 8, 2021 14:28
Show Gist options
  • Save mentix02/c33acf8a8f513479f6ef2b95223216eb to your computer and use it in GitHub Desktop.
Save mentix02/c33acf8a8f513479f6ef2b95223216eb to your computer and use it in GitHub Desktop.
class Node:
def __init__(self, data):
self.data = data
self.next = None
class List:
def __init__(self):
self.head = None
def addInEnd(self, el):
newNode = Node(el)
if self.head is None:
self.head = newNode
return
else:
tmp = self.head
while tmp.next:
tmp = tmp.next
tmp.next = newNode
def display(self):
node = self.head
while node:
print(node.data)
node = node.next
l = List()
l.addInEnd(3)
l.addInEnd(5)
l.addInEnd(6)
l.display()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment