Write a function in Python pop(S), where S is a stack implemented by a list
of items. The function returns the value deleted from the stack.
Answers
Answered by
1
Answer:
1. Create a class Stack with instance variable items initialized to an empty list.
2. Define methods push, pop and is_empty inside the class Stack.
3. The method push appends data to items.
4. The method pop pops the first element in items.
5. The method is_empty returns True only if items is empty.
6. Create an instance of Stack and present a menu to the user to perform operations on the stack
Explanation:
Answered by
2
Answer:
def pop(S):
wh=int(input("what do you want to remove :"))
S.pop(wh)
print("new list:",S)
pop(S)
Similar questions