Created
December 8, 2021 14:28
-
-
Save mentix02/c33acf8a8f513479f6ef2b95223216eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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