Skip to content

Commit

Permalink
LINKED LIST IN PYTHON yshshrm#1377 CLOSES
Browse files Browse the repository at this point in the history
  • Loading branch information
unikamittal committed Oct 10, 2019
1 parent ac97dbe commit 5ff19b4
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions unika/unika.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# A simple Python program for implementing linked list in python
# Node class
class Node:
# Function to initialise the node object
def __init__(self, data):
self.data = data # Assign data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
# This function prints contents of linked list
# starting from head
def printList(self):
temp = self.head
while (temp):
print temp.data,
temp = temp.next
# Code execution starts here
if __name__=='__main__':
# Start with the empty list
llist = LinkedList()
llist.head = Node(1)
second = Node(2)
third = Node(3)

llist.head.next = second; # Link first node with second
second.next = third; # Link second node with the third node

llist.printList()

0 comments on commit 5ff19b4

Please sign in to comment.