Computer Science, asked by praveenyadav032003, 6 months ago

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 jai696
3

\large\mathsf\color{pink}{Solution\: using\: python\: 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)}")

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Answered by nerdier
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