-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathll.py
More file actions
47 lines (41 loc) · 1.06 KB
/
ll.py
File metadata and controls
47 lines (41 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# single linked list
class Node():
def __init__(self,data):
self.data=data
self.next=None
class single_linkedlist():
def __init__(self):
self.Head=None
self.tail=None
self.count=0
def take_inputs(self):
data=[int(i) for i in input('enter data').split(" ")]
#[10,20,30,40]
if len(data)==0:
return 0
for i in data:
node=Node(i)
if self.count==0:
self.head=node
self.tail=node
else:
self.tail.next=node
self.tail=node
self.count+=1
return self.head
def print_linklist(self,head):
if head is None:
return head.data
while head is not None:
print(head.data,end='->')
head=head.next
def add_node(self):
pass
def delete_node(self):
pass
def size(self):
return self.count
list=single_linkedlist()
head=list.take_inputs()
list.print_linklist(head)
print(list.count)