CBSE Class 12 Computer Science Question 31 of 63

Data Structures in Python — Question 5

Back to all questions
5
Question

Question 5

Write an algorithm to push an element into the Stack.

Answer

An algorithm to push an element into the Stack is as follows:

  1. START
  2. Stack = list() or Stack = [] #Initialize a Stack using list
  3. element = input("Enter the value to be added in the stack:")
  4. Stack.append(element) #Adding element into list
  5. END