Post

Day 21 of 100 Days of Python

Practising Linked Lists

Today I started a new topic of DSA, Linked Lists.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Linked List

class Node:
    def __init__(self,data):
        self.data = data
        self.next=None

node1 = Node(10)
node2 = Node(20)
node3 = Node(30)

node1.next = node2
node2.next = node3
current = node1
while current is not None:
    print(current.data, end=" -> ")
    current = current.next
print("None")

Output:

1
10 -> 20 -> 30 -> None
This post is licensed under CC BY 4.0 by the author.

Trending Tags