We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d4fb375 commit 38570b9Copy full SHA for 38570b9
1 file changed
Day-104/stack-1.py
@@ -0,0 +1,30 @@
1
+#!/usr/bin/env python3
2
+
3
+# Stacks in Python using lists
4
+import random
5
6
+class Stack():
7
+ """
8
+ Stack class
9
10
11
+ def __init__(self):
12
+ self.items = []
13
14
+ def push(self, item):
15
+ self.items.append(item)
16
17
+ def pop(self, item):
18
+ self.items.pop(item)
19
20
+ def get_stack(self):
21
+ return self.items
22
23
24
25
+stack_1 = Stack()
26
+for i in range(1, 25):
27
+ j = random.randint(1, 25)
28
+ stack_1.push(j)
29
30
+print("Stack 1: {}".format(stack_1.get_stack()))
0 commit comments