forked from anythingth2/DataStructure_and_Algorithm_Practice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1
30 lines (28 loc) · 677 Bytes
/
1
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
class node:
def __init__(self,data):
self.data = data
self.next = None
class linkedlist:
def __init__(self):
self.head = self.tail = None
def __str__(self):
output =''
n = self.head
while n is not self.tail:
output += n.data
n = n.next
output+=n.data
return output
def append(self,data):
if self.head == None:
self.head = node(data)
self.tail = self.head
else:
tail = self.tail
tail.next = node(data)
self.tail = tail.next
x = linkedlist()
x.append('a')
x.append('b')
x.append('c')
print(x)