We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 90593d2 + 2c0a4c6 commit 0d1301aCopy full SHA for 0d1301a
data_structures/Python/linklist.py
@@ -0,0 +1,27 @@
1
+class Node:
2
+ def __init__(self, dataval=None):
3
+ self.dataval = dataval
4
+ self.nextval = None
5
+
6
+class SLinkedList:
7
+ def __init__(self):
8
+ self.headval = None
9
10
+ def listprint(self):
11
+ printval = self.headval
12
+ while printval is not None:
13
+ print (printval.dataval)
14
+ printval = printval.nextval
15
16
+list = SLinkedList()
17
+list.headval = Node("Mon")
18
+e2 = Node("Tue")
19
+e3 = Node("Wed")
20
21
+# Link first Node to second node
22
+list.headval.nextval = e2
23
24
+# Link second Node to third node
25
+e2.nextval = e3
26
27
+list.listprint()
0 commit comments