STACK
STACK
names and price as a node, whose prices are below 500 into the stack. Also pop all
the elements as well as display the elements. List description: [pid, pname, price]
stk=[]
l=[]
def products():
n=int(input("enter no. of records: "))
for i in range(n):
pid=int(input("enter product id: "))
pname=input("enter product name: ")
price=int(input("enter price: "))
l.append([pid,pname,price])
def push():
for i in l:
if i[-1]<500:
stk.append([i[1],i[-1]])
for i in range(len(stk)-1,-1,-1):
print(stk[i])
else:
print("stack bottom")
def pop():
if len(stk):
while stk:
print(stk.pop())
else:
print("stack empty ")
else:
print("underflow")