Created
February 5, 2021 13:56
-
-
Save devashishpatil56/b291480db232d4b1dc6db932ce02b675 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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