Skip to content

Commit 6bff826

Browse files
Merge pull request TheAlgorithms#41 from theycallmemac/patch-2
Create __init__.py
2 parents 0dbd2df + 4a8fa8b commit 6bff826

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Node:
2+
def __init__(self, item, next):
3+
self.item = item
4+
self.next = next
5+
6+
class LinkedList:
7+
def __init__(self):
8+
self.head = None
9+
10+
def add(self, item):
11+
self.head = Node(item, self.head)
12+
13+
def remove(self):
14+
if self.is_empty():
15+
return None
16+
else:
17+
item = self.head.item
18+
self.head = self.head.next
19+
return item
20+
21+
def is_empty(self):
22+
return self.head == None

0 commit comments

Comments
 (0)