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 803366a commit 43f7a3bCopy full SHA for 43f7a3b
implement_stack_python.py
@@ -0,0 +1,33 @@
1
+# implement_stack_python
2
+
3
+class Stack:
4
+ def __init__(self):
5
+ self.items = []
6
+ def push(self, value):
7
+ self.items.append(value)
8
+ def size(self):
9
+ return len(self.items)
10
+ def is_empty(self):
11
+ return len(this.items) == 0
12
+ def pop(self):
13
+ if len(self.items) == 0:
14
+ return None
15
+ return self.items.pop()
16
17
18
+MyStack = Stack()
19
20
+MyStack.push("Web Page 1")
21
+MyStack.push("Web Page 2")
22
+MyStack.push("Web Page 3")
23
24
+print (MyStack.items)
25
26
+MyStack.pop()
27
28
29
+print ("Pass" if (MyStack.items[0] == 'Web Page 1') else "Fail")
30
31
32
33
+print ("Pass" if (MyStack.pop() == None) else "Fail")
0 commit comments