Skip to content

Commit 38570b9

Browse files
author
Vimal A R
committed
* Stack
1 parent d4fb375 commit 38570b9

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Day-104/stack-1.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)