Skip to content

Commit 479d737

Browse files
authored
Merge pull request #1 from dheerajmalviy/main
A program for LinkedList in phyton
2 parents 1a315ca + f3369f0 commit 479d737

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Diff for: LinkList in phyton

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# A simple Python program to introduce a linked list
2+
3+
# Node class
4+
class Node:
5+
6+
# Function to initialise the node object
7+
def __init__(self, data):
8+
self.data = data # Assign data
9+
self.next = None # Initialize next as null
10+
11+
12+
# Linked List class contains a Node object
13+
class LinkedList:
14+
15+
# Function to initialize head
16+
def __init__(self):
17+
self.head = None
18+
19+
20+
# Code execution starts here
21+
if __name__=='__main__':
22+
23+
# Start with the empty list
24+
llist = LinkedList()
25+
26+
llist.head = Node(1)
27+
second = Node(2)
28+
third = Node(3)
29+
llist.head.next = second; # Link first node with second
30+
second.next = third;

0 commit comments

Comments
 (0)