Skip to content

Create __init__.py #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions data_structures/LinkedList/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Node:
def __init__(self, item, next):
self.item = item
self.next = next

class LinkedList:
def __init__(self):
self.head = None

def add(self, item):
self.head = Node(item, self.head)

def remove(self):
if self.is_empty():
return None
else:
item = self.head.item
self.head = self.head.next
return item

def is_empty(self):
return self.head == None