Write a function in Python POP_OUT(Stk), where Stk is a stack
implemented by a list of numbers. The function returns the value which is
deleted/popped from the stack.
Answers
Answered by
3
def POP_OUT(Stk):
if len(Stk) > 0:
item = Stk[-1]
del Stk[-1]
return item
l = [int(n) for n in range(1, 11)]
for _ in range(10):
print(f"popped {POP_OUT(l)}")
Answered by
0
Answer:
def POP_OUT(Stk):
rem=int(input("what do you want to remove :"))
s=Stk.pop(rem)
print("deleted value:",s)
print("new list:",Stk)
Similar questions