Def Isempty (STK)
Def Isempty (STK)
if stk==[]:
return True
else:
return False
def push(stk,pn,pm):
l=[pn,pm]
stk.append(l)
print("added successfully")
def pop(stk):
if isEmpty(stk):
print("stack empty")
else:
print("the popped item is :",stk.pop())
def display(stk):
if isEmpty(stk):
print("stack Empty")
else:
top=len(stk)-1
print("top item is:",stk[top])
for a in range (top-1,-1,-1):
print(stk[a])
def peek(stk):
if isEmpty(stk):
print("stack Empty")
else:
top=len(stk)-1
print("top item is ........:",stk[top])
stk=[]
top=None
while True:
print("stack operations")
print("1.push")
print("2.pop")
print("3.display")
print("4.peek")
print("5.Exit")
ch=int(input("enter your choice(1-5):"))
if ch==1:
pn=input("enter processor name:")
pm=input("enter processor model:")
push(stk,pn,pm)
elif ch==2:
item=pop(stk)
if item=="underflow":
print("stack Empty")
else:
print("deleted item is :",item)
elif ch==3:
display(stk)
elif ch==4:
peek(stk)
elif ch==5:
print("existing")
break
else:
print("invalid choice")