Fewpal
0 votes
647 views
in Computer by (45.7k points)
closed by

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.

1 Answer

+1 vote
by (48.9k points)
selected by
 
Best 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)

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...