FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Python_Programs/stack.py at main · MayankVerma105/Python_Programs · GitHub
MayankVerma105
/
Python_Programs
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
5
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Python_Programs
/
stack.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
33 lines (26 loc) · 758 Bytes
Breadcrumbs
Python_Programs
/
stack.py
Copy path
File metadata and controls
33 lines (26 loc) · 758 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class
Stack
:
def
__init__
(
self
):
self
.
values
=
list
()
def
push
(
self
,
element
):
self
.
values
.
append
(
element
)
def
isEmpty
(
self
):
return
len
(
self
.
values
)
==
0
def
pop
(
self
):
if
not
(
self
.
isEmpty
()):
return
self
.
values
.
pop
()
else
:
print
(
'Stack Underflow'
)
return
None
def
top
(
self
):
if
not
(
self
.
isEmpty
()):
return
self
.
values
[
-
1
]
else
:
print
(
'Stack Empty'
)
return
None
def
size
(
self
):
return
len
(
self
.
values
)
def
__str__
(
self
):
stringRepr
=
''
for
i
in
reversed
(
self
.
values
):
stringRepr
+=
str
(
i
)
+
'
\t
'
return
stringRepr
Back
|
FazBrowse Home
|
New Git URL