Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def convert_collection_to_stack(_collection):
- return Stack(*_collection.values()) if isinstance(_collection, dict) else Stack(*_collection)
- class Stack:
- def __init__(self, *args):
- self._collection = list(args) if len(args) else []
- def push(self, item):
- self._collection.append(item)
- def pop(self):
- return self._collection.pop() if len(self._collection) else None
- def get_stack_as_list(self):
- return self._collection
Add Comment
Please, Sign In to add comment