jtentor icon

DemoStack1 - Python - StackList.py

jtentor | PRO | 05/11/20 08:52:12 PM UTC | 0 ⭐ | 435 👁️ | Never ⏰ | []
Python |

860 B

|

None

|

0 👍

/

0 👎

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
__author__ = 'Julio Tentor <[email protected]>'
 
 
class Stack(object):
    def __init__(self, capacity = 10):
        self.__datos = []
 
    def Push(self, elemento):
        self.__datos.append(elemento)
 
    def Pop(self):
        if self.Empty:
            raise ValueError("ERROR La pila está vacía...")
        return self.__datos.pop()
 
    def Peek(self):
        if self.Empty:
            raise ValueError("ERROR La pila está vacía...")
        return self.__datos[len(self.__datos) - 1]
 
    def Top(self):
        return self.Peek()
 
    @property
    def Empty(self):
        return len(self.__datos) == 0
 
    @property
    def Count(self):
        return len(self.__datos)
 
    def __str__(self):
        return str(self.__datos)
 
 
if __name__ == "__main__":
    pass

Comments