-
Notifications
You must be signed in to change notification settings - Fork 0
/
linkedlist.py
47 lines (44 loc) · 1.32 KB
/
linkedlist.py
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
class node:
def __init__(self,data):
self.data = data
self.next = None
#self.temp = None
class linkedlist:
def __init__(self):
self.head = None
#self.temp = None
if __name__ == "__main__":
llist = linkedlist()
def insert(element,llist,temp):
if(llist.head==None):
llist.head = node(element)
temp = llist.head
print(llist.head)
else:
#llist.temp = node(element)
#llist.temp = node(element)
#tempo = node(element)
#temp = tempo
while(temp.next==None):
temp.next = node(element)
temp = temp.next
break
return temp
condition =True
while(condition == True):
print("1.Insert\n2.Delete\n3.Print\n4.Exit")
option = int(input())
if(option ==1):
element = int(input())
if(llist.head==None):
#llist.head = node(element)
x=insert(element,llist,temp=None)
else:
x = insert(element,llist,x)
if(option ==2):
element = int(input())
delete(element)
elif(option == 3):
printlist()
elif(option == 4):
condition = False