Computer Science, asked by ankitmaurya36, 5 months ago

Write a user define function in Python for push(list) and pop(list) for

performing push and pop operations with a stack of list containing integers.​

Answers

Answered by jai696
12

\huge\red{\mid{\fbox{\tt{Using\: Python\: 3}}\mid}}

def push(item, stack):

stack += [item]

return stack

def pop(stack):

if stack:

item = stack[-1]

stack.remove(item)

return item

stack = [n for n in range(1, 11)]

for x in range(10, 21):

push(x, stack)

for _ in range(len(stack)):

print(pop(stack))

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

Similar questions