What is Stack?

<aside> 💡 Stack is a linear structure that enable data to input and remove from the same edge, so it follows the last system in first out (LIFO). The insertion and the deletion each of them is recognized as push() and pop()

</aside>

Untitled

# Stack
stack = ['first', 'second', 'thrid']
print(stack)

print()

#pushing elements
stack.append('fourth')
stack.append('fifth')
print(stack)
print()

# printing top
print(stack[-1])
print()

# poping element
stack.pop()
print(stack)
['first', 'second', 'thrid']

['first', 'second', 'thrid', 'fourth', 'fifth']

fifth

['first', 'second', 'thrid', 'fourth']