0% found this document useful (0 votes)
7 views1 page

Push

The document describes a stack operation program that uses a while loop to continuously prompt the user to push, pop, peek at or display elements in a stack, appending elements to the stack with a push function and breaking the loop if the user enters 5.

Uploaded by

samata
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Push

The document describes a stack operation program that uses a while loop to continuously prompt the user to push, pop, peek at or display elements in a stack, appending elements to the stack with a push function and breaking the loop if the user enters 5.

Uploaded by

samata
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

def push (stk,elt):

stk.append(elt)
print ("element inserted...")
print(stk)

stack=[]
while True:
print("......stack operation.....")
print(" 1.push")
print(" 2.pop")
print(" 3.peek")
print(" 4.display")
ch=int(input("enter your choice"))
if ch==1:
element =int(input("enter the element which you want to push"))
push(stack,element)
elif ch==5:
break

You might also like