1.

Write the push operation of stack containing names using class.

Answer»

class stack:

s=[]

def push(self):

a=r’aw_input(“Enter any name :”)

stack.s.append(a)

def display(self):

l=len(stack.s) for i in range(l-1,-1,-1):

print stack.s[i]

a=stackO

n= input(“Enter no. of names”)

for i in range (n):

a.push()

a.display()



Discussion

No Comment Found