CBSE Class 12 Computer Science Question 44 of 63

Data Structures in Python — Question 18

Back to all questions
18
Question

Question 18(i)

Write an algorithm to insert element into Stack as a list.

Answer

An algorithm to insert element into Stack as a list 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