Computer Science, asked by saurabhshrimali000, 6 months ago

Write a function in Python POP(Arr), where Arr is a stack implemented by a

list of numbers. The function returns the value deleted from the stack.​

Answers

Answered by jai696
4

\large\mathsf\color{pink}{Solution\: using\: python\: 3}

def POP(Arr):

if len(Arr) > 0:

item = Arr[-1]

del Arr[-1]

return item

nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

for _ in range(len(nums)):

print(f"Popped: {POP(nums)}")

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

Answered by duragpalsingh
1

Question:

Write a function in Python POP(Arr), where Arr is a stack implemented by a list of numbers. The function returns the value deleted from the stack.​

Solution:

def popStack(st) :

# If stack is empty

if len(st)==0:

print("Underflow")

else:

L = len(st)

val=st[L-1]

print(val)

st.pop(L-1)

Learn More on Brainly.in:

Your friend Sunita complaints that somebody has created a fake profile on Twitter and defaming her character with abusive comments and pictures. Identify the type of cybercrime for these situations.

https://brainly.in/question/30095565

Suppose a tuple T is declared as T = (10, 12, 43, 39) , which of the following is incorrect? a) rint * (T[1]) b) T[2] = - 29 c) print * (max * (T)) d) print (len * (T))​

https://brainly.in/question/30819138

Similar questions