Problem: — Write a function that clears all the elements of a Stack. The function should take a Stack as an input parameter and remove all the elements in it. Input: stack = [1, 2, 3, 4, 5]
Output: stack = []
Input: stack = ["apple", "banana", "cherry"]
Output: stack = []
Input: stack = []
Output: stack = [] Solution: To clear all the elements from a stack, we can simply use the clear() method of list in Python. This method removes all the elements from the list.