Computer Science, asked by shivangiraj66, 7 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 duragpalsingh
0

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

Answered by nerdier
0

Answer: Down below is the answer plz mark me brainiest

Explanation:#wap in python to perform push and pop on a stack implemented as a list

d=[]

x=int(input("how many numbers you want to create in list:"))

for j in range(0,x):

   s=int(input("enter a number:"))

   d.append(s)

def push():

   how=int(input("upto how much ?:"))

   for i in range(0,how):

       put=int(input("enter the number:"))

       d.append(put)

   print("new list:",d)

def pop():

   wh=int(input("what do you want to remove :"))

   d.pop(wh)

   print("new list:",d)

choice=int(input("enter your choice 1 for push() and 2 for pop():"))

if choice==1:

   push()

elif choice==2:

   pop()

Similar questions