<jupyter_start><jupyter_text>Discussion 2: StacksA `stack` is a collection of objects that are inserted and removed according to the *last in, first-out* (**LIFO**) principle.  A developers may insert objects into a stack at any time, but may only remove the most recent object first.  The **stack** name comes from the idea of cafeteria plat dispenser.  A bunch of plates are loaded and stacked on each other, but only the last one added can be removed first.  The **stack** involves two operations: **push** and **pop**.  A push operation, we push down data ontop of the stack.  When we pop, we remove the top most dataset from the stack.   Examples of Usage:These are one of the most common data structures:- Web Browser- Text Editor Undo ButtonA stack must implement the following:```pythons.push()  adds a value to the top of the stacks.pop()  removes the value from the stsacks.top()  Returns the top most value without removing its.is_empty()  returns a boolean value to see if values exist in the stacklen(s)  returns  the depth of the stack``` Helpful Links:1. https://docs.python.org/3/tutorial/datastructures.html Discussion Problem:Create your own stack using a Python `list` and post your code.  Explain what you did, and why you did it this way.  Use the `Class` below to assist you getting started.  All the methods that are needed are in the `class`. A note on the code below the class Stack.  That is simple test code.  If you run it and nothing displays, then you did it correctly.  You can use this code to test your solution!<jupyter_code>class Stack(object):
    """LIFO Stack Implementation"""
    _data = None
    def __init__(self):
        self._data = []
    def __len__(self):
        return len(self._data)
    def is_empty(self):
        """returns True if the stack is empty"""
        return len(self._data) == 0
    def push(self, value):
        """adds an element to the top of the stack"""
        self._data.append(value)
    def top(self):
        """
        returns but does not remove the top most value in the stack
        """
        if self.is_empty():
            return None
        else:
            return self._data[-1]
    def pop(self):
        """removes and returns the element from the top of the stack"""
        if self.is_empty():
            return None
        else:
            return self._data.pop()
s = Stack()
s.push(1)
assert s.is_empty() == False
print(s.pop())
assert s.is_empty() == True
s.push(2)
s.push(3)
assert len(s) == 2
assert s.top() == 3<jupyter_output>1
{'fraction_non_alphanumeric': 0.08889766890557092, 'fraction_numerical': 0.00434610825760569, 'mean_word_length': 3.1037277147487843, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '532957', 'license': 'Apache-2.0', 'n_tokens_mistral': 714, 'n_tokens_neox': 697, 'n_words': 346, 'path': 'discussion/Discussion Topic 03 - Stacks.ipynb', 'repo_name': 'shaheen19/Adv_Py_Scripting_for_GIS_Course', 'size': '2531'}