We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent edaf097 commit 3153e22Copy full SHA for 3153e22
Stack/Stack.py
@@ -0,0 +1,25 @@
1
+class Stack:
2
+ def __init__(self):
3
+ self.items = []
4
+
5
+ def push(self,item):
6
+ self.items.append(item)
7
8
+ def size(self):
9
+ return len(self.items)
10
11
+ def is_empty(self):
12
+ return len(self.items) == 0
13
14
+ def pop(self):
15
+ if self.is_empty():
16
+ raise IndexError("Error, your Stack is empty.")
17
+ return self.items.pop()
18
19
+ def top(self):
20
21
22
+ return self.items[-1]
23
24
+ def clear(self):
25
0 commit comments