Skip to content

Instantly share code, notes, and snippets.

@vamsitallapudi
Created June 11, 2020 14:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save vamsitallapudi/d6cdc37f82f154558ca4b6909215a80d to your computer and use it in GitHub Desktop.
class Node:
def __init__(self, data):
self.data = data # assigning the data passed
self.next = None # initializing the node as null
class LinkedList:
def __init__(self):
self.head = None
def traverse(self):
node = self.head
while node is not None:
print(node.data)
node = node.next
# actual code execution starts from here
if __name__ == '__main__':
linkedList = LinkedList()
linkedList.head = Node('a')
second = Node('b')
third = Node('c')
linkedList.head.next = second
second.next = third
linkedList.traverse()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment