Skip to content

Instantly share code, notes, and snippets.

@devashishpatil56
Created February 5, 2021 13:56
Show Gist options
  • Save devashishpatil56/b291480db232d4b1dc6db932ce02b675 to your computer and use it in GitHub Desktop.
Save devashishpatil56/b291480db232d4b1dc6db932ce02b675 to your computer and use it in GitHub Desktop.
def createStack():
return []
def isEmpty(stack):
if len(stack)==0:
return True
else:
return False
def push(stack, element):
stack.append(element)
def pop(stack):
if isEmpty(stack):
raise ValueError("Stack is Empty")
else:
stack.pop()
def top(stack):
if isEmpty(stack):
print("Stack is Empty")
return None
else:
return stack[-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment