1.

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.

Answer»

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)



Discussion

No Comment Found

Related InterviewSolutions