Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'Shail'
- a = list();
- n = int(input("Size of stack: "));
- count = 0;
- while True:
- print(a[:]);
- choice = int(input("1.Push 2.Pop 3.Exit: "));
- if choice == 1:
- if count == n: print("Stack is full.");
- else:
- a.append(input("Enter a number to push: "));
- count += 1;
- elif choice == 2:
- if count == 0: print("Stack is empty.");
- else:
- del a[count-1];
- count -= 1;
- elif choice == 3:
- break;
- else: print("Enter 1, 2, or 3.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement