NOTE Modify append() function so that it will enable you to push more items using (Y/N): E.g Enter your Choice: 1 Push item to stack: 12 Enter more(y/n): y Push item to stack: 15 Enter more(y/n): n Modify pop() function so that it will confirm user want to delete item or not,(give warning that item deleted cannot be recovered) using (Delete/Cancel): E.g (D/C) Add There (#) comment and declear all the line of this coding properly. ALGORITHM Steps: For Array/List Based, Declare and initialize necessary variables, eg size. Initialize an empty list as myStack; 1.Use while loop to get input from user. 2.Continue while loop until list size and defined size are same; if len(list) == size print “Stack overflow“ else Read item from user myStack = item 3.For next append operation, goto step 2. 4.For pop operation, checks that your defined size is equal to list size or not; if len(list) == size print "Stack underflow" else myStack = pop(); Display item 5.For next pop operation, goto step 4. 6.Stop Modify the algorithm given, stack.py, to create a Menu that enable user to enter option for stack operations append() pop() Count last item of the list len(list) == 0 and check whether list is full or not len() print()
NOTE
Modify append() function so that it will enable you to push more items using (Y/N): E.g
Enter your Choice: 1 Push item to stack: 12 Enter more(y/n): y Push item to stack: 15 Enter more(y/n): n
Modify pop() function so that it will confirm user want to delete item or not,(give warning that item deleted cannot be recovered) using (Delete/Cancel): E.g (D/C)
Add There (#) comment and declear all the line of this coding properly.
For Array/List Based, Declare and initialize necessary variables, eg size.
Initialize an empty list as myStack;
1.Use while loop to get input from user.
2.Continue while loop until list size and defined size are same;
if len(list) == size
print “Stack overflow“
else
Read item from user
myStack = item
3.For next append operation, goto step 2.
4.For pop operation, checks that your defined size is equal to list size or not;
if len(list) == size print "Stack underflow"
else
myStack = pop(); Display item
5.For next pop operation, goto step 4.
6.Stop
Modify the algorithm given, stack.py, to create a Menu that enable user to enter option for stack operations
- append()
- pop()
- Count last item of the list
- len(list) == 0 and check whether list is full or not
- len()
- print()
Step by step
Solved in 3 steps with 8 images