aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-095/abigail/python/ch-2.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/challenge-095/abigail/python/ch-2.py b/challenge-095/abigail/python/ch-2.py
new file mode 100644
index 0000000000..ab91e0303c
--- /dev/null
+++ b/challenge-095/abigail/python/ch-2.py
@@ -0,0 +1,27 @@
+import fileinput
+import re
+
+stack = []
+error = "Stack is empty"
+for line in fileinput . input ():
+ chunks = line . split ()
+ command = chunks [0]
+
+ if command == "push":
+ stack . append (int (chunks [1]))
+
+ if command == "pop":
+ if len (stack):
+ stack . pop ()
+
+ if command == "top":
+ if len (stack):
+ print stack [len (stack) - 1]
+ else:
+ print error
+
+ if command == "min":
+ if len (stack):
+ print min (stack)
+ else:
+ print error